【发布时间】:2017-11-28 22:54:31
【问题描述】:
我正在尝试通过其中一个键的值来获取数组中的对象。
数组:
{
"privileges" :
[
{
"resource" : "login" ,
"actions": ["true"]
},
{
"resource": "user" ,
"actions": ["create","read"]
}
]
}
【问题讨论】:
-
请问预期的结果是什么?
-
我输入了 console.log(user.role.privileges) 我得到了这个权限:[ { '0': [Object], '1': [Object], actions: [] } ] }
-
@HaythemHedfi 您接受的答案不包含与 MongoDB 相关的任何内容,他们为什么要使用这些标签?
标签: javascript node.js mongoose mongoose-schema