【发布时间】:2020-03-25 23:27:06
【问题描述】:
我正在尝试使用sails-hook-deep-orm 在sails js 中进行多次填充。我想过滤省份ID。 我正在使用最新版本的 Sails 和 Node。我使用 MySQL 作为数据库。
这是我的模型:
// Province.js
attributes: {
name: {
type: 'string',
required: true
},
description: {
type: 'string',
required: false
},
cities: {
collection: 'city',
via: 'province'
}
}
// City.js
attributes: {
name: {
type: 'string',
required: true
},
description: {
type: 'string',
required: false
},
province: {
model: 'province'
},
communities: {
collection: 'community',
via: 'city'
}
}
// Community.js
attributes: {
name: {
type: 'string',
required: true
},
description: {
type: 'string',
required: false
},
cities: {
collection: 'city',
via: 'province'
}
}
我已经尝试过:
Community.find()
.populate('city.province', {'city.province.id' : 1});
Community.find()
.populate('city.province', { where: { 'city.province.id': 1 } });
代码仍未过滤。我希望这个案子能得到解决。谢谢你:)
【问题讨论】:
标签: javascript node.js sails.js sails-orientdb