I expect to find something like doc = {'_id' : 1000, "site : {"lentreprise|express|fr" : 1}, "total" : 1} in the collection but it just inserts empty documents like { "_id" : ObjectId("4fabf4d7e1bd727dc2fca36d")
}
What do I need to do in order to be able to perform upserts on the _id field?
> I expect to find something like doc = {'_id' : 1000, "site :
> {"lentreprise|express|fr" : 1}, "total" : 1} in the collection but it just
> inserts empty documents like { "_id" : ObjectId("4fabf4d7e1bd727dc2fca36d")
> }
> What do I need to do in order to be able to perform upserts on the _id
> field?
> Thanks,
> /David
> --
> You received this message because you are subscribed to the Google Groups
> "mongodb-user" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/mongodb-user/-/KB6GnTd_CiMJ.
> To post to this group, send email to mongodb-user@googlegroups.com.
> To unsubscribe from this group, send email to
> mongodb-user+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/mongodb-user?hl=en.
I reconstructed the exact same query in Java - the JSON I printed above was generated by calling .toString() on the DBObjects, yet - using the Java driver I find it impossible to upsert - at least on "_id" fields. I haven't found any complaints so I must be doing something wrong.
On Thursday, May 10, 2012 7:43:43 PM UTC+2, Scott Hernandez wrote:
> Can you produce the behavior you want in the mongo javascript shell > and post the example?
> On Thu, May 10, 2012 at 10:29 AM, David the Dude <ogd...@googlemail.com> > wrote: > > Hello,
> > I can't get an upset to work with the Java driver. The upsert in > question is > > on an _id which just for testing I set to 1000 for testing purposes.
> > BasicDBObject findCriterion = new BasicDBObject(); > > BasicDBObject incClause = new BasicDBObject(); > > BasicDBObject incDoc = new BasicDBObject();
> > ... I populate the incClause and incDoc, the final query looks like this > > (toString) > > // findCriterion: { "_id" : 1000} > > // incClause: { "total" : 1 , "site.lentreprise|lexpress|fr" : 1} > > // incDoc: { "$inc" : { "total" : 1 , "site.lentreprise|lexpress|fr" : > 1}}
> > I expect to find something like doc = {'_id' : 1000, "site : > > {"lentreprise|express|fr" : 1}, "total" : 1} in the collection but it > just > > inserts empty documents like { "_id" : > ObjectId("4fabf4d7e1bd727dc2fca36d") > > }
> > What do I need to do in order to be able to perform upserts on the _id > > field?
> > Thanks,
> > /David
> > -- > > You received this message because you are subscribed to the Google > Groups > > "mongodb-user" group. > > To view this discussion on the web visit > > https://groups.google.com/d/msg/mongodb-user/-/KB6GnTd_CiMJ. > > To post to this group, send email to mongodb-user@googlegroups.com. > > To unsubscribe from this group, send email to > > mongodb-user+unsubscribe@googlegroups.com. > > For more options, visit this group at > > http://groups.google.com/group/mongodb-user?hl=en.