环回多个 where 子句客户端

Loopback multiple where clause client side

我正在尝试使用 Loopback 的 AngularJS SDK,但我没有找到使用多个 where 子句执行请求的方法(并且文档中没有示例)。

$scope.events = Professional.events({
        id: '1',
        filter: {
          where: {
            EndDate: {gt: new Date("2017-05-20T00:00:00.000Z")}
          }
        }
      },
    function(err) {
      [...]
    });

这个例子非常有效,但我想这样做:

$scope.events = Professional.events({
        id: '1',
        filter: {
          where: {
            and: {
              EndDate: {gt: new Date("2017-05-20T00:00:00.000Z")},
              EndDate: {it: new Date("2017-06-20T00:00:00.000Z")}
            }
          }
        }
      },
    function(err) {
      [...]
    });

终端显示的错误

Error: The and operator has invalid clauses {"EndDate":{"it":"2017-06-20T00:00:00.000Z"}}: Value is not an array or object with sequential numeric indices

再试一次:

$scope.events = Professional.events({
    id: '1',
    filter: {
      where: {
        EndDate: {gt: new Date("2017-05-20T00:00:00.000Z")},
        EndDate: {it: new Date("2017-06-20T00:00:00.000Z")}
      }
    }
  },
function(err) {
  [...]
});

显示完全相同的错误代码。 有什么想法吗?

编辑:此解决方案无效

$scope.events = Professional.events({
        id: '1',
        filter: {
          where: {
            and: [
              {EndDate: {gt: new Date("2017-05-20T00:00:00.000Z")} },
              {EndDate: {it: new Date("2017-06-20T00:00:00.000Z")} }
            ]

          }
        }
      }
      ,
    function(err) {
      [...]
    });

代码错误 (500 http)

Erreur non traitée pour la demande GET /api/Professionals/1/events?filter=%7B%22where%22:%7B%22and%22:%5B%7B%22EndDate%22:%7B%22gt%22:%222017-05-20T00:00:00.000Z%22%7D%7D,%7B%22EndDate%22:%7B%22it%22:%222017-06-20T00:00:00.000Z%22%7D%7D%5D%7D%7D : Error: Date non valide : [object Object]

如果您尝试将多个条件与 and 进行比较,您必须将数组传递给并像这样:

where: 
{
    and: [
        {title: 'My title'}, 
        {content: 'Hello'}
    ]
}

上面的代码意味着给我所有标题为 'My title' 且内容为 'Hello'.

的数据

你的情况是:

where: {
    and: [
        { EndDate: {gt: new Date("2017-05-20T00:00:00.000Z")} },
        { EndDate: {it: new Date("2017-06-20T00:00:00.000Z")} }
    ]
}