Javascript 环回引用数组不工作的许多关系
当我在Javascript 环回引用数组不工作的许多关系,javascript,node.js,mongodb,loopbackjs,loopback,Javascript,Node.js,Mongodb,Loopbackjs,Loopback,当我在环回中使用带有数组的relation引用多个。当我删除引用多个关系时,出现了错误。我正在使用环回3 {“错误”:{ “状态代码”:500, “名称”:“错误”, “消息”:“5D53EAA49B826748F0B72CA5不是ObjectID字符串”, }} 这是我的json模式: { "name": "Products", "plural": "Products", "strict": true, "idInjection": true, "options": {
环回
中使用带有数组的relation引用多个
。当我删除引用多个
关系时,出现了错误
。我正在使用环回3
{“错误”:{
“状态代码”:500,
“名称”:“错误”,
“消息”:“5D53EAA49B826748F0B72CA5不是ObjectID字符串”,
}}
这是我的json模式:
{
"name": "Products",
"plural": "Products",
"strict": true,
"idInjection": true,
"options": {
"validateUpsert": true
},
"mixins": {
"TimeStamp": true
},
"properties": {
"name": {
"type": "string",
"default": ""
},
"image": {
"type": [],
"required": true,
"default": []
},
"about": {
"type": "string",
"required": true,
"default": ""
},
"categoryId": {
"type": [],
"required": false,
"default": []
},
"userId": {
"type": "string",
"required": true,
"default": ""
},
"storeId": {
"type": "string",
"required": true,
"default": ""
},
"location": {
"type": "geopoint",
"required": false
},
"price": {
"type": "object",
"required": true,
"default": {
"discount": "",
"actualRate": "",
"finalRate": ""
}
},
"createdAt": {
"type": "date"
},
"updatedAt": {
"type": "date"
}
},
"validations": [],
"relations": {
"userDeatils": {
"type": "belongsTo",
"model": "Users",
"foreignKey": "userId"
},
"categories": {
"type": "referencesMany",
"model": "Categories",
"foreignKey": "categoryId"
},
"storeDeatils": {
"type": "belongsTo",
"model": "Users",
"foreignKey": "userId"
}
},
"acls": [
{
"accessType": "*",
"principalType": "ROLE",
"principalId": "admin",
"permission": "ALLOW"
},
{
"accessType": "*",
"principalType": "ROLE",
"principalId": "$authenticated",
"permission": "ALLOW"
},
{
"accessType": "WRITE",
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "ALLOW"
},
{
"accessType": "*",
"principalType": "ROLE",
"principalId": "$unauthenticated",
"permission": "DENY"
}
],
"methods": {}
}
{
"name": "deara",
"image": ["dsadsa"],
"about": "dear ser",
"categoryId": [
"5d53eaa49b826748f0b72ca5"
],
"userId": "dsdsadsa",
"storeId": "dsdsadsadsad",
"location": {
"lat": 0,
"lng": 0
},
"price": {
"discount": "121",
"actualRate": "321",
"finalRate": "231"
},
"createdAt": "2019-08-09T12:02:54.514Z",
"updatedAt": "2019-08-09T12:02:54.514Z"
}
我的json数据对象如下:
{
"name": "Products",
"plural": "Products",
"strict": true,
"idInjection": true,
"options": {
"validateUpsert": true
},
"mixins": {
"TimeStamp": true
},
"properties": {
"name": {
"type": "string",
"default": ""
},
"image": {
"type": [],
"required": true,
"default": []
},
"about": {
"type": "string",
"required": true,
"default": ""
},
"categoryId": {
"type": [],
"required": false,
"default": []
},
"userId": {
"type": "string",
"required": true,
"default": ""
},
"storeId": {
"type": "string",
"required": true,
"default": ""
},
"location": {
"type": "geopoint",
"required": false
},
"price": {
"type": "object",
"required": true,
"default": {
"discount": "",
"actualRate": "",
"finalRate": ""
}
},
"createdAt": {
"type": "date"
},
"updatedAt": {
"type": "date"
}
},
"validations": [],
"relations": {
"userDeatils": {
"type": "belongsTo",
"model": "Users",
"foreignKey": "userId"
},
"categories": {
"type": "referencesMany",
"model": "Categories",
"foreignKey": "categoryId"
},
"storeDeatils": {
"type": "belongsTo",
"model": "Users",
"foreignKey": "userId"
}
},
"acls": [
{
"accessType": "*",
"principalType": "ROLE",
"principalId": "admin",
"permission": "ALLOW"
},
{
"accessType": "*",
"principalType": "ROLE",
"principalId": "$authenticated",
"permission": "ALLOW"
},
{
"accessType": "WRITE",
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "ALLOW"
},
{
"accessType": "*",
"principalType": "ROLE",
"principalId": "$unauthenticated",
"permission": "DENY"
}
],
"methods": {}
}
{
"name": "deara",
"image": ["dsadsa"],
"about": "dear ser",
"categoryId": [
"5d53eaa49b826748f0b72ca5"
],
"userId": "dsdsadsa",
"storeId": "dsdsadsadsad",
"location": {
"lat": 0,
"lng": 0
},
"price": {
"discount": "121",
"actualRate": "321",
"finalRate": "231"
},
"createdAt": "2019-08-09T12:02:54.514Z",
"updatedAt": "2019-08-09T12:02:54.514Z"
}
我不明白我哪里错了。
提前感谢环回预期
dsadsad232323
将是另一个模型的对象的标识符,因此categoryId
必须是id的数组是categoryId是id的数组。这是我唯一能解决问题的例子。