我使用 loopback 来生成我的 api 和 AngularJS 来与之通信。我有一个名为的模型Sync
,其中包含以下记录:
Sync": {
"34": "{\"uuid\":\"287c6625-4a95-4e11-847e-ad13e98c75a2\",\"table\":\"Property\",\"action\":\"create\",\"timeChanged\":1466598611995,\"id\":34}",
"35": "{\"uuid\":\"287c6625-4a95-4e11-847e-ad13e98c75a2\",\"table\":\"Property\",\"action\":\"update\",\"timeChanged\":1466598625506,\"id\":35}",
"36": "{\"uuid\":\"176aa537-d000-496a-895c-315f608ce494\",\"table\":\"Property\",\"action\":\"update\",\"timeChanged\":1466598649119,\"id\":36}"
}
在我的 sync.js 模型文件中,我正在尝试编写以下接受数字(long - timeChanged)的方法,并且应该返回所有具有相等或相等 timeChanged 字段的记录。
这就是我所在的位置:
Sync.getRecodsAfterTimestamp = function(timestamp, cb){
var response = [];
Sync.find(
function(list) {
/* success */
// DELETE ALL OF THE User Propery ratings associated with this property
for(i = 0; i < list.length; i++){
if(list[i].timeChanged == timestamp){
response += list[i];
console.log("Sync with id: " + list[i].id);
}
}
cb(null, response);
},
function(errorResponse) { /* error */ });
}
Sync.remoteMethod (
'getRecodsAfterTimestamp',
{
http: {path: '/getRecodsAfterTimestamp', verb: 'get'},
accepts: {arg: 'timeChanged', type: 'number', http: { source: 'query' } },
returns: {arg: 'name', type: 'Array'}
}
);
当我在环回资源管理器中尝试这种方法时,我看到了这个“AssertionError”