我正在尝试使用以下查询更新具有匹配嵌套属性的文档
upsertByCommentThreadId: function(commentThread) {
return CommentThreads.update({
'youtube.commentThreadId': commentThread.youtube.commentThreadId
},
{
$set: commentThread
},
{
upsert: true
}
);
}
架构:
Schema({
youtube: {
type: Object
},
'youtube.etag': {
type: String
},
'youtube.commentThreadId': {
type: String,
index: 1
},
...
但我得到一个错误
Exception while invoking method ... MongoError: The dotted field 'youtube.commentThreadId' in 'youtube.commentThreadId' is not valid for storage.
如果不是通过点表示法,我不确定我还能如何查询嵌套属性
最佳答案
这是mongo 3.6之前对字段名的限制,现在可以将mongo server升级到3.6或更高版本来解决这个问题。
https://docs.mongodb.com/manual/reference/limits/#naming-restrictions
关于mongodb - MongoError : The dotted field .。对存储无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30014243/