【发布时间】:2019-10-10 11:24:16
【问题描述】:
我有一个模型批次,其数据为
"id": {
"type": "string",
"id": true,
"defaultFn": "uuidv4"
},
"batchType": {
"type": "string",
"required": true,
"default": "COURSE"
},
"venue": {
"type": "string",
"required": true
},
另一个模特说预定浴场
"batchesId": {
"type": [
"string"
],
"required": true
},
并创建了从批次模型到bookedBatches 模型的关系
"relations": {
"bookedBatches": {
"type": "referencesMany",
"model": "bookedBatches",
"foreignKey": "batchesId",
"primaryKey": "id"
}
}
现在我想要所有带有预订详细信息的批次,这些批次在批次模型的预订详细信息中存储为 ID 数组
let reqObject = {
"where": {
"and": [{
userId: userId,
isActive: true
}]
},
"order": "createdAt DESC",
include: [
{{
relation:"bookedBatches"}}]
}
Batches.find(reqObject, (resError, resData) => {
if (resError) {
return cb(new HttpErrors.BadRequest(resError, {
expose: false
}))
}
return cb(null, resData);
})
但我没有得到任何价值,任何人都可以帮助通过关系获得价值
谢谢!
【问题讨论】:
标签: mongodb foreign-keys relationship loopback