BSON

Syntax

"$sort": SON([("name", 1)])

Example

from bson.son import SON 

mydb.mycollection.aggregate([
{$match’ : {$text’ : {$search’ : ‘ value ’}}},
{$sort’ : SON([(‘ field ’, 1)])}, # from bson.son import SON {‘$project’ : {‘ field1 ’ : 1, ‘ field2 ’ : 1, ‘ field3 ’ : 0}}
])
 

Last updated

Was this helpful?