如何使用GORM将内部对象字段更新为MongoDB?

时间:2017-11-15 15:02:37

标签: mongodb grails

数据库中对象的字段未更新且没有错误。

class Transaction {
    static mapWith = "mongo"
    ObjectId id
    String name
    Address address
    static embedded = ['address']
}
class Address {
    String country
}

def tempMethod() {
    def transaction = Transaction.first()
    transaction.address = new Address(country: "Canada")
    transaction.save(flush: true, failOnError: true)
}

0 个答案:

没有答案