You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import std/[
oids,
asyncdispatch,
]
import nimongo/bson
import nimongo/mongo
proctest_sync2=var m =newMongo()
doAssert m.connect()
let mc = m["tmp"]["tnimongo"]
let doc =%*{
"name": "bob4",
}
for i in0..<2:
# doc["number"] = toBson i# echo doclet ai = mc.insert(doc)
echo ai
doAssert ai
test_sync2()
maybe behavior of Nim is ok, and derives from fact that Bson is a reference type (unlike Bson in Nim); this could have advantages in terms of efficiency (avoiding copies), but IMO should be clearly documented in README that insert modifies input Bson (unlike other implementations, eg D, mongo shell)
The text was updated successfully, but these errors were encountered:
timotheecour
changed the title
[critical] inserting the same Bson object doesn't re-generate _id, resulting in a single insert
needs documentation in README: insert(bson) modifies bson; re-inserting will have no effect
Nov 17, 2018
this generates a single insert:
the equivalent code in D generates 2 inserts:
likewise with other clients, eg the mongo shell client
edit
in python, it behaves same as Nim (well almost, minus the fact that python will throw, see #66)
maybe behavior of Nim is ok, and derives from fact that Bson is a reference type (unlike Bson in Nim); this could have advantages in terms of efficiency (avoiding copies), but IMO should be clearly documented in README that
insert
modifies input Bson (unlike other implementations, eg D, mongo shell)workaround
pending nim-lang/Nim#9740 we can do:
The text was updated successfully, but these errors were encountered: