0
我試圖從包含特定主題的老師數組中刪除領域,如"ok baby"
在mongoDb中,如何刪除包含特定鍵和值的數組中的對象?
{
"_id" : "billy",
"password" : "$2a$10$MKZFNtMhts6rMbnIoqXB9.Q8NHAizQAGhX5S6g.8zeRt7TpRpuQea",
"teacher" : [
{
"subject" : "ok baby",
"students" : [
"billy"
]
},
{
"subject" : "adsfqewr",
"students" : [
"billy"
]
}
]
}
這是我的嘗試:
users.update( { 'teacher.subject':title, '_id':username},
{ $pull: { 'teacher.subject':title } },
{ multi: true }
)
似乎並沒有那樣做 – Squirrl
哦,我把「稱號'而不是主題再試 –
是否有用? –