strong循环环回-在相关模型上使用过滤器的REST示例?

strong循环环回-在相关模型上使用过滤器的REST示例?,rest,loopbackjs,strongloop,Rest,Loopbackjs,Strongloop,我发现这个示例使用节点API将过滤器应用于相关模型,但我想知道是否可以使用REST实现相同的结果 节点示例: Post.find({ include: { relation: 'owner', // include the owner object scope: { // further filter the owner object fields: ['username', 'email'], // only show two fields in

我发现这个示例使用节点API将过滤器应用于相关模型,但我想知道是否可以使用REST实现相同的结果

节点示例:

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() { ... });
我能找到的最接近REST url的版本是:

...?filter[include][owners][orders]

通过基于相关模型过滤器限制结果,是否可以创建与上述节点示例行为相同的REST url。。。在这种情况下,订单?

我有这个函数,所以当我调用Hdates/coming REST API时,它会显示日期大于今天的事件,还包括场馆。。。希望能有帮助

  Hdate.coming = function(cb) {
    Hdate.find({         
         where : { 
            event_date :{gt: Date.now()}
          },
          include : {
            relation: 'event', 
            scope : {
              include: {
                relation: 'venue'
              }
            }
          }   
    }, cb);
  };
  Hdate.setup = function() {
    Hdate.base.setup.apply(this, arguments);
    this.remoteMethod('coming', {
      description: 'Find Coming Events by Date',
      returns: {arg: 'events', root: true},
      http: { verb: 'GET' }
    });
  };
  Hdate.setup();

你看到了吗?是的,但是没有一个使用REST的示例,其中过滤器应用于相关模型。我确实发现,您可以将节点API JSON字符串化并将其用作查询字符串,这样就可以了,尽管它不像url的REST版本那么容易阅读。下面有一些示例,您可能在寻找
…?过滤器[include][orders][id]=5&字段[username]=true&字段[email]=true
。不过我还没测试过。我会试试看,然后再报告。谢谢