DATADOC-16 added updateMulti and updateFirst methods
This commit is contained in:
@@ -237,11 +237,11 @@ public class MongoTemplate implements InitializingBean {
|
||||
}
|
||||
}
|
||||
|
||||
public void update(DBObject queryDoc, DBObject updateDoc) {
|
||||
update(getRequiredDefaultCollectionName(), queryDoc, updateDoc);
|
||||
public void updateFirst(DBObject queryDoc, DBObject updateDoc) {
|
||||
updateFirst(getRequiredDefaultCollectionName(), queryDoc, updateDoc);
|
||||
}
|
||||
|
||||
public void update(String collectionName, DBObject queryDoc, DBObject updateDoc) {
|
||||
public void updateFirst(String collectionName, DBObject queryDoc, DBObject updateDoc) {
|
||||
WriteResult wr = null;
|
||||
try {
|
||||
wr = getDb().getCollection(collectionName).update(queryDoc, updateDoc);
|
||||
@@ -250,6 +250,19 @@ public class MongoTemplate implements InitializingBean {
|
||||
}
|
||||
}
|
||||
|
||||
public void updateMulti(DBObject queryDoc, DBObject updateDoc) {
|
||||
updateMulti(getRequiredDefaultCollectionName(), queryDoc, updateDoc);
|
||||
}
|
||||
|
||||
public void updateMulti(String collectionName, DBObject queryDoc, DBObject updateDoc) {
|
||||
WriteResult wr = null;
|
||||
try {
|
||||
wr = getDb().getCollection(collectionName).updateMulti(queryDoc, updateDoc);
|
||||
} catch (MongoException e) {
|
||||
throw new DataRetrievalFailureException("Error during updateMulti using " + queryDoc + ", " + updateDoc + ": " + wr.getLastError().getErrorMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
public void remove(DBObject queryDoc) {
|
||||
remove(getRequiredDefaultCollectionName(), queryDoc);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user