I'm trying to overload a method, allowing it to increment the count of several documents in a one multi update to optimize DB accessing. The current (single update) method looks like:
static synchronized void updateDb(String col, DBObject oldDoc) {
DBCollection collection = database.getCollection(col);
BasicDBObject inc = new BasicDBObject().append("$inc", new BasicDBObject().append("count", 1));
collection.update(new BasicDBObject().append("url",oldDoc.get("url").toString()), inc);
}
Now I have looked into update multi and bulk.find.update() but haven't found a solution yet. Basically I want to hand over an (thread-safe) deque of DBObjects to the new method, and have the DB do most of the rest.
PS: the snag I hit is, that I can't get by with a simple find/query, but instead have a collection (best deque) of urls to query for.
Any advice?