sách gpt4 ai đã đi

Sails.js 填充 where

In lại 作者:行者123 更新时间:2023-12-04 23:19:52 31 4
mua khóa gpt4 Nike

我需要选择带狗的用户(带 kiểu 等于“狗”的宠物)

var User = Waterline.Collection.extend({

identity: 'user',

attributes: {
firstName: 'string',
lastName: 'string',

pets: {
collection: 'pet',
via: 'owner'
}
}
});

var Pet = Waterline.Collection.extend({

identity: 'pet',

attributes: {
type: 'string',
name: 'string',

owner: {
model: 'user'
}
}
});

我没有找到任何例子,我试过这样
User.find().populate('pets', {type: 'dog'}).exec(err, users) ...

和这个
User.find().where({'pets.type': 'dog'}).populate('pets').exec(err, users) ...

但这不起作用

如果结果用户数组将没有宠物记录,那就太好了

1 Câu trả lời

你试过这个吗?

User.find().populate('pets', {
where: {
type: 'dog'
}
}).exec(err, users)...

关于Sails.js 填充 where,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30225945/

31 4 0
行者123
Hồ sơ cá nhân

Tôi là một lập trình viên xuất sắc, rất giỏi!

Nhận phiếu giảm giá Didi Taxi miễn phí
Mã giảm giá Didi Taxi
Giấy chứng nhận ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com