-
Dec 10th, 2012, 12:48 PM
#1
Spring MongoDB: Save a collection (Set, List..) in bulk?
In Spring MongoDB is it possible to upsert a collection in bulk, i.e without iterating it and saving every item separately?
-
Jan 3rd, 2013, 02:55 PM
#2
The short answer is no. But not because of Spring Data, but because bulk upserts in Mongo are not supported. I believe it is a JIRA/Feature that might show up later in future versions of Mongo.
I have had this issue before myself with Mongo, no Spring Data usage. And I always had to really think about what I wanted done and come up with either a different document model, or another alternative.
For instance, in one case, instead of upserting different elements in a collection, I would update the entire collection. So I would get the document, get the collection and modify it in code, then do a $set on the collection to the new version of it. It will still be an update statement which allows for WriteConcerns rather than a full document replacement in the database.
Hope that helps, and sorry almost a month since you first posted this, so you probably already came up with an alternative.
Mark
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules