Ich habe Loopback verwendet, um meine API und AngularJS zu generieren, um damit zu kommunizieren. Ich habe ein Modell Sync
genannt, die folgende Datensätze enthält:LoopBack Remote Methode zum Zurückgeben von Array von Datensätzen
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}"
}
in meiner sync.js Modell-Datei Ich versuche, die folgende Methode zu schreiben, die Nummer akzeptiert (long - die timeChanged) und soll alle Datensätze zurückgeben Das sind gleiche oder gleiche TimeChanged Feld.
Dies ist, wo ich bin:
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'}
}
);
Wenn ich diese Methode im Explorer Loopback versuche ich, dieses "AssertionError" sehen
Dank! hat funktioniert! :) –