我对Angular SDK和lb-service非常不熟悉,并且对如何通过控制器内的ID查询其他用户信息感到困惑
我想创建一个朋友列表功能,每个用户只存储他们朋友的ID。帐户属性如下所示
"name": "account",
"base": "User",
"idInjection": true,
"options": {
"validateUpsert": true
},
"properties": {
"email": {
"type": "string",
"required": true
},
"password": {
"type": "string",
"required": true
},
"firstName": {
"type": "string",
"required": true
},
"lastName": {
"type": "string",
"required": true
},
"gender": {
"type": "string",
"required": true,
"default": "Male"
},
"contact": {
"type": "number"
},
"friends": {
"type": [
"string"
]
},
"status": {
"type": "string"
}
}
},
"acls": [
{
"accessType": "READ",
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "ALLOW"
},
{
"accessType": "*",
"principalType": "ROLE",
"principalId": "$owner",
"permission": "ALLOW"
},
{
"accessType": "READ",
"principalType": "ROLE",
"principalId": "$unauthenticated",
"permission": "DENY"
},
{
"accessType": "*",
"principalType": "ROLE",
"principalId": "admin",
"permission": "ALLOW"
}
]
从lb-services.js看,我可以使用findById函数查找用户,但如何查询朋友的属性以获取每个用户的信息?
答案 0 :(得分:0)
根据索引样式的ID查询用户的信息,朋友是包含查询功能的每个用户的数组:
function userById(id){
return friends[id];
}
获取每个用户信息:
for(var i = 0;i<friends.length;i++){
console.log(userById(i));
}