【发布时间】:2017-08-30 15:30:32
【问题描述】:
我有一个像这样的猫鼬数据:
{
"_id" : ObjectId("58e394cacaa6512ed00e8d83"),
"RoleName" : "Manager",
"UIList" : [
{
"Edit" : false,
"View" : false,
"UiName" : "ElevatorMapping"
},
{
"Edit" : false,
"View" : false,
"UiName" : "ElevatorAssumptions"
},
{
"Edit" : false,
"View" : false,
"UiName" : "ManageUnits"
},
{
"Edit" : false,
"View" : false,
"UiName" : "ManageBuildings"
}
],
"__v" : 0,
"Description" : "fd",
"IsActive" : true
}
现在我想将 UIname:"ElevatorMapping"&"Elevator Assumptions" View and Edit 中的 UILIST 更新为 True。如何为此编写查询?我尝试过类似下面的方法。
这是我的控制器页面。
$http.put('/ViewEditupdate/' + id +'/' + uiname + '/' + view + '/' + edit).then(function (response) {
refresh();
})
此处的 id 值被正确采用,但编辑视图 UI 名称未被采用。编辑,视图名称被视为未定义。
我的 server.js 代码
app.put('/ViewEditupdate/:id/:uiname/:view/:edit', RoleEntrypath.RoleViewEditupdate);
我的架构代码
newRole.update({ "UIList.UiName": "ManageRole" }, { "$push": { "UIList.$.View": "true", "UIList.$.Edit": "true" } },
function (err, doc) {
res.json(doc);
}
);
谁能给出解决方案?
【问题讨论】:
-
很难跟进您的问题。你为什么不试着用更简单的术语来表达呢?
-
嗨 ankit,我已经更新了我的问题
-
你能打印你的 put API 中的所有参数值吗?首先,让我们看看你是否收到了正确的价值观。如果您收到正确的值,那么问题可能出在
update查询上。
标签: angularjs node.js mongoose