SSPkrolik / nimongo

Pure Nim lang MongoDB driver
http://sspkrolik.github.io/nimongo
MIT License
101 stars 20 forks source link

Support for projections in find() #69

Open AjBreidenbach opened 5 years ago

AjBreidenbach commented 5 years ago

It is currently not possible to perform complex find queries with projections such as

db.stores.find(
   { $text: { $search: "java coffee shop" } },
   { score: { $meta: "textScore" } }
).sort( { score: { $meta: "textScore" } } )

We could keep the convenient function signature and api proc find*[T:Mongo|AsyncMongo](c: Collection[T], filter: Bson, fields: seq[string] = @[]): Cursor[T], but include the following for additional use-cases: proc find*[T:Mongo|AsyncMongo](c: Collection[T], fields: varargs[Bson]): Cursor[T]

Internally Cursor[T].fields would have to be represented as a BSON object