Merge: mongodb: auto generate ObjectId for inserted and saved documents
authorJean Privat <jean@pryen.org>
Tue, 30 Jun 2015 00:48:48 +0000 (20:48 -0400)
committerJean Privat <jean@pryen.org>
Tue, 30 Jun 2015 00:48:48 +0000 (20:48 -0400)
commit66f163ef17ddf1d1eb3d6f7ae268f32571880cd3
treeed183101795f6219ddaf3cdec89fbc02580ff8f0
parent5bd84f2bc190237b37e9a9d371aa2bc28d88fe40
parent0646f544ada9005ea98b794890ffac73e2912fa4
Merge: mongodb: auto generate ObjectId for inserted and saved documents

This PR enables the generation of unique ObjectIds for new JsonObject added to collection.

Example when inserting a document:
~~~nit
var obj = new JsonObject
obj["foo"] = "bar"
print obj.to_json
~~~

Object before insertion:
~~~json
{
   "foo": "bar"
}
~~~

After insertion:
~~~nit
collection.insert(obj)
print obj.to_json
~~~
~~~json
{
   "_id": {"$oid": "5578e5e5f34422650c27af01"},
   "foo": "bar"
}
~~~

Pull-Request: #1500
Reviewed-by: Jean Privat <jean@pryen.org>
Reviewed-by: Romain Chanoir <chanoir.romain@courrier.uqam.ca>
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>