mongodb - 使用 $pull 和 Deployd 方法
问题描述
我有一个 Deployd API,它公开了一个像这样的 json 结构:
[
{id: "1"
username: "john",
password: " ..... ",
email: "example@gmail.com",
coins: 60,
badges: [ ],
courses:[
{ id: "123456",
title: "Animals",
grades_per_module: [ [30], [28, 26], [25, 24]]
.....
},
{ id: "112233",
title: "Food",
grades_per_module: [ [20, 25, 27], [22]]
.....
}
]
},
{id: "2"
username: "mark",
password: " ..... ",
email: "ex@gmail.com",
coins: 40,
badges: [ ],
courses:[
{ id: "123456",
title: "Animals",
grades_per_module: [ [27], [21, 30], [30, 30]]
.....
}
]
}
]
然后我需要使用角码删除用户“john”的 id="112233" 的兴趣课程。
所以我使用这段代码,但它不起作用:
this.http.put('http://localhost:2403/users/1',
{ "courses": { $pull: { "id": 112233 } }
}).subscribe( ..... )
已部署的 API 向我返回了一个肯定的消息,但课程并没有真正从用户对象中删除。谁能帮我?
解决方案
推荐阅读
- system-verilog - SystemVerilog 断言:使用两个时钟
- python - 增加 XGBClassifier 中少数类的召回率
- c# - Entity Framework 6 fluent api删除n:n关系上的级联
- javascript - 在 Internet Explorer 中的 svg 上使用 AppendChild 是错误的
- css - 我可以在过渡中指定变换属性吗?
- gcc - 如何使用 gcov 修复与覆盖范围相关的“geninfo: ERROR path/to/i386.gcno: could not open file”
- matrix - 使用 UKF 进行定向有没有办法将卡尔曼滤波器中的冗余传感器数据融合到一组状态变量中?
- ruby-on-rails - minitest 在测试载波时显示错误
- android - 从 ProgressBar 中删除背景边框
- javascript - React Native - 根据其父答案处理动态表单