环回远程方法未返回正确的值

Loopback remote method not returning correct values

我使用 loopback 的框架来生成我的 API。现在,我正在尝试编写一个自定义“RemoteMethod”,它需要一个长数字(unix 格式的时间戳,例如 1466598625506)和 return 一个同步对象数组(我正在使用改造来与端点通信)。在我的 android 应用程序中,当我调用终点“getRecodsAfterTimestamp”时,它应该 return timeStamp 值等于或大于请求中提供的记录的记录。 What It returns 是所有记录(此时为3条)。

这就是我的模型 (sync.json) 调用 Sync 的样子:

{
"name": "Sync",
"base": "PersistedModel",
"idInjection": true,
"options": {
"validateUpsert": true
},
"properties": {
"uuid": {
  "type": "string"
},
"table": {
  "type": "string"
},
"action": {
  "type": "string"
},
"timeChanged": {
  "type": "number"
}
},
"validations": [],
"relations": {},
"acls": [],
"methods": {}
}

这是我的 sync.js 远程方法如下所示:

module.exports = function(Sync) {

Sync.getRecodsAfterTimestamp = function(timestamp, cb){
// var response;

Sync.find({where:{ or: [
  {timeChanged:timestamp},
  {timeChanged: {gt:timestamp } }
] }}, function(err, sync) {
   cb(null,sync);
  // response.push(sync);
});

// cb(null, response);
}

Sync.remoteMethod (
'getRecodsAfterTimestamp',
{
  http: {path: '/getRecodsAfterTimestamp', verb: 'get'},
  accepts: {arg: 'timeChanged', type: 'number', http: { source: 'query' } },
  returns: {
    arg: 'data',
    type: 'array',
    root: true
  }
 }
);


};

我不知道这是否重要,但这是我的改造方法声明:

@GET("Syncs")
Call<List<Sync>> getAllSyncsAfterThisTimeStamp(@Query(("getRecodsAfterTimestamp?timeChanged=")) long timeChanged);

我在这里这样称呼它:

Long timeStamp = 1466598625506L;
Log.e(TAG, "Job Service task is running...");
getAllSyncsCall = espcService.getAllSyncsAfterThisTimeStamp(timeStamp);
getAllSyncsCall.enqueue(EspcJobSheculerService.this);

这段代码returns

这不是我想要的结果。它应该 return 编辑了 1466598625506 之后的所有记录,这只是两条记录。

您的查询是正确的。

检查 find 回调你是否得到正确的输出