SSPkrolik / nimongo

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

Inserted _id list tracked in StatusReply #47

Closed JohnAD closed 6 years ago

JohnAD commented 6 years ago

This update adds any missing _id from inserted documents and stores those in a seq[Bson] in StatusReply so that end user can identify the newly inserted documents. This is akin to what the Mongo Shell and related libraries typically do:

ref: issue #45

JohnAD commented 6 years ago

@SSPkrolik ,

Mind reviewing this branch? For the project I'm working on, getting insert to return a driver-generated _ids is critical to it's function. I've got a work around for the moment, but as I use nimongo more I'd rather not depend on the work-around.

BTW, returning the _id is the same behavior seen in the Mongo shell and the other official libraries.

https://docs.mongodb.com/manual/applications/drivers/

And, from the MongoDB specifications for drivers:

https://github.com/mongodb/specifications/blob/master/source/crud/crud.rst#write

/**
   * Inserts the provided document. If the document is missing an identifier,
   * the driver should generate one.
   *
   * @see https://docs.mongodb.com/manual/reference/command/insert/
   * @throws WriteException
   */
SSPkrolik commented 6 years ago

Thx for the contribution!