@@ -172,19 +172,23 @@ class MongoPluginSupport {
172
172
* http://code.google.com/p/morphia/wiki/Updating
173
173
*/
174
174
metaClass. update = { Closure data , boolean createIfMissing = false , WriteConcern wc = null ->
175
- if (! delegate. ident()) {
176
- throw new IllegalStateException (" Cannot update instances without an id" )
177
- }
178
- def query = datastore. createQuery(delegate. class)
179
- def updateOp = datastore. createUpdateOperations(delegate. class)
175
+ update(data, createIfMissing, false , wc)
176
+ }
180
177
181
- query. filter(Mapper . ID_KEY , delegate. ident());
178
+ metaClass. update = { Closure data , boolean createIfMissing = false , boolean multi = true , WriteConcern wc = null ->
179
+ if (! delegate. ident()) {
180
+ throw new IllegalStateException (" Cannot update instances without an id" )
181
+ }
182
+ def query = datastore. createQuery(delegate. class)
183
+ def updateOp = datastore. createUpdateOperations(delegate. class)
182
184
183
- data. delegate = updateOp
184
- data()
185
+ query. filter(Mapper . ID_KEY , delegate. ident());
185
186
186
- def updateResult = datastore. update(query, updateOp, createIfMissing, wc)
187
- }
187
+ data. delegate = updateOp
188
+ data()
189
+
190
+ datastore. update(query, updateOp, createIfMissing, multi, wc)
191
+ }
188
192
189
193
metaClass. delete = { ->
190
194
triggerEvent(EVENT_BEFORE_DELETE , delegate)
@@ -297,20 +301,24 @@ class MongoPluginSupport {
297
301
}
298
302
299
303
metaClass. static . update = { filter , Closure data , boolean createIfMissing = false , WriteConcern wc = null ->
300
- if (! (filter instanceof Map )) filter = [(Mapper . ID_KEY ): _checkedId(domainClass, filter)]
304
+ update(filter, data, createIfMissing, false , wc)
305
+ }
301
306
302
- def query = datastore . createQuery(domainClass . clazz)
303
- def updateOp = datastore . createUpdateOperations (domainClass. clazz)
307
+ metaClass . static . update = { filter , Closure data , boolean createIfMissing = false , boolean multi = true , WriteConcern wc = null ->
308
+ if ( ! (filter instanceof Map )) filter = [( Mapper . ID_KEY ): _checkedId (domainClass, filter)]
304
309
305
- filter. each { k , v ->
306
- query. filter(k. toString(), v)
307
- }
310
+ def query = datastore. createQuery(domainClass. clazz)
311
+ def updateOp = datastore. createUpdateOperations(domainClass. clazz)
308
312
309
- data. delegate = updateOp
310
- data()
313
+ filter. each { k , v ->
314
+ query. filter(k. toString(), v)
315
+ }
311
316
312
- def updateResult = datastore. update(query, updateOp, createIfMissing, wc)
313
- }
317
+ data. delegate = updateOp
318
+ data()
319
+
320
+ datastore. update(query, updateOp, createIfMissing, multi, wc)
321
+ }
314
322
315
323
/**
316
324
* creates a new instance of this class and populates fields from DBObject
0 commit comments