Mongodb 如何创建Meteor Mongo验证对象操作符?

Mongodb 如何创建Meteor Mongo验证对象操作符?,mongodb,meteor,Mongodb,Meteor,在尝试更新Meteor/MongoDB记录时,我遇到了一个错误,我真的无法将其放在适当的位置。以下是我在.update上的尝试以及由此产生的错误消息: > Profiles.update(currentProfile()._id, {latlng: latlng}) 错误:当修饰符选项为true时,验证对象必须至少有一个运算符 这个验证对象是什么?我如何至少给它一个操作符 如果我使用$set运算符,它实际上不会执行任何操作: Profiles.update(currentProfile(

在尝试更新Meteor/MongoDB记录时,我遇到了一个错误,我真的无法将其放在适当的位置。以下是我在.update上的尝试以及由此产生的错误消息:

> Profiles.update(currentProfile()._id, {latlng: latlng})
错误:当修饰符选项为true时,验证对象必须至少有一个运算符

这个验证对象是什么?我如何至少给它一个操作符

如果我使用$set运算符,它实际上不会执行任何操作:

Profiles.update(currentProfile()._id, {$set: {latlng: latlng}})

Profiles.find(currentProfile()._id).fetch()
[ 
_id: "wuzriXfcS2PxBmwcE"
email: "kasper.souren@example.com"
github: "guaka"
name: "Kasper"
twitter: "guaka"
userId: "G4gNTtwQj6rSkwyob"
__proto__: Object
]

注意没有latlng

我想您应该使用$set操作符:

Profiles.update(currentProfile()._id, {$set: {latlng: latlng}})
你能试试吗

Profiles.update({_id: currentProfile()._id}, {$set: {latlng: latlng}})

您是否尝试过获取_id的实际值并使用它,而不是从currentProfile中获取它?这是什么意思?currentProfile.\u id如何不是实际值?该值是否显示在实际数据库中?是否可能是由于服务器上的字段选项导致latlng未发布?我在使用SimpleSchema时遇到此错误,可能与此有关?