Javascript Loopback.io包含多个模型查询条件
对于单个模型查询,我们可以对查询中定义的条件应用条件操作,其中and/or运算符应用于一系列条件:Javascript Loopback.io包含多个模型查询条件,javascript,node.js,loopbackjs,Javascript,Node.js,Loopbackjs,对于单个模型查询,我们可以对查询中定义的条件应用条件操作,其中and/or运算符应用于一系列条件: { where: {<and|or>: [condition1, condition2, ...]}} 是否可以在上述条件1、条件2上应用和/或操作,即返回所有模型,使其与所包含模型范围内定义的条件相匹配。我相信您可以按照以下代码示例执行此操作: Post.find({ include: { relation: 'owner', // include the owner
{ where: {<and|or>: [condition1, condition2, ...]}}
是否可以在上述条件1、条件2上应用和/或操作,即返回所有模型,使其与所包含模型范围内定义的条件相匹配。我相信您可以按照以下代码示例执行此操作:
Post.find({
include: {
relation: 'owner', // include the owner object
scope: { // further filter the owner object
fields: ['username', 'email'], // only show two fields
include: { // include orders for the owner
relation: 'orders',
scope: {
where: {orderId: 5} // only select order with id 5
}
}
}
}
}, function() { ... });
这是为包含过滤器记录的
Post.find({
include: {
relation: 'owner', // include the owner object
scope: { // further filter the owner object
fields: ['username', 'email'], // only show two fields
include: { // include orders for the owner
relation: 'orders',
scope: {
where: {orderId: 5} // only select order with id 5
}
}
}
}
}, function() { ... });