MongoDB findAndModify() with aggregation

Alan DeKok aland at deployingradius.com
Fri Mar 20 15:16:48 CET 2020


On Mar 20, 2020, at 8:05 AM, Benjamin Thompson <b.thompson at latera.ru> wrote:
> 
> The findAndModify() method was recently updated to support
> aggregation. This means that the "update" parameter now accepts two
> different sytaxes:
> 
> Old syntax (no aggregation):
> db.collection.findAndModify(query: { ... }, update: { ... } )
> 
> New syntax (with aggregation):
> db.collection.findAndModify(query: { ... }, update: [ ... ] )
> 
> The difference being that square bracket are used instead of curly
> bracktes for the aggregation pipeline.
> 
> The first syntax works with FreeRADIUS but the second syntax gives the error:
> 
> rlm_sql_mongo: 'update' does not hold a document.

  It's not clear why... I'm not a Mongo expert.  I just read the MongoC API, and poked things until it worked.  The API is pretty good, which helped.

> If there is any possiblitly to support the aggregation option then I
> think this would be very useful as it allows much more complex data
> processing inside the request.

  Sure.  What API does the module have to use?

  Alan DeKok.




More information about the Freeradius-Users mailing list