Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/467.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Loopback.io包含多个模型查询条件_Javascript_Node.js_Loopbackjs - Fatal编程技术网

Javascript Loopback.io包含多个模型查询条件

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

对于单个模型查询,我们可以对查询中定义的条件应用条件操作,其中and/or运算符应用于一系列条件:

{ 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() { ... });