Search code examples
mongodbgrailsgroovygrails-orm

GORM standalone: no updateOne() with maps


In my good'ol grails (3.1.x) app I have lines like

  ModuleState.collection.updateOne( 
    [ compositeKey:ck ], 
    [ $set:[ compositeKey:ck, dateUpdated:new Date(), online:true ] ], 
    [ upsert:true ] )

In my grails-free app with GORM standalone:

compile 'org.grails:grails-datastore-gorm-mongodb:6.0.4.RELEASE'

this line throws an exception

groovy.lang.MissingMethodException: No signature of method: com.mongodb.MongoCollectionImpl.updateOne() is applicable for argument types: (java.util.LinkedHashMap, java.util.LinkedHashMap, java.util.LinkedHashMap) values: [[compositeKey:111], [$set:[...]], ...] Possible solutions: updateOne(org.bson.conversions.Bson, org.bson.conversions.Bson), updateOne(org.bson.conversions.Bson, org.bson.conversions.Bson, com.mongodb.client.model.UpdateOptions)

so, the new map-consuming methods are not injected.

Any way to fix it and make GORM great again?


Solution

  • You need to add org.grails:grails-datastore-gorm-mongodb-ext:6.0.4.RELEASE to your classpath