我無法搞清楚這是什麼錯誤意味着神祕的MongoDB的錯誤LEFT_SUBFIELD只支持對象:統計不:6
LEFT_SUBFIELD只支持對象:統計不:6
這似乎是發生在我我正在插入我的個人資料集合。我正在使用mongoose.js。我們在統計信息屬性中插入每個類別的帖子數量,例如
stats: {category:count, category2: count2}.
這裏是我的架構
var ProfileSchema = new Schema({
uname: {
type: String,
required: true,
index: true,
unique: true
},
fname: String,
lname: String,
stats: {
type:{},
"default":{},
required:true
},
created: {
type:Date,
required:true,
"default":Date.now
}
});
我想可能當我更新的統計對象$ INC計數,使統計數據能夠出來這樣的更新是發生
db.status.update({_id:xyz}, {$inc: { stats.foo : 1, stats.bar:1}})
這是我的貓鼬編碼
var tags = ["comedy", "action", "drama"];
//also adding the postId to the posts collection of profile
var updateCommand = {$push: {posts: post._id}};
var stats = {};
for (var i = tags.length - 1; i >= 0; i--){
stats["stats." + tags[i].toString()] = 1;
};
updateCommand.$inc = stats;
Profile.update(
{uname: uname},
updateCommand,
{safe:true, upsert:true},
callback
);
這正是,謝謝你的帖子!如果我撓了一下頭,我有點討厭工作。 – Aktau 2013-06-27 14:06:30