Settopending (f, fb) ist die erste aufgerufene Funktion, ich bin mir nicht sicher, ob ich die Rückrufe nicht korrekt geschrieben habe, weil applytransaction (t, f, fb) nie aufgerufen wird. "First" und "Second" werden gedruckt, aber "Third" und "Fourth" werden nicht gedruckt. Habe ich den Callback falsch eingerichtet, der applytransaction (t, f, fb) aufrufen soll oder gibt es da noch etwas anderes?Node.JS Callback-Funktion wird nicht ausgeführt
function update(document,f,fb)
{
this.transactions.update(
{ _id: document._id, state: "initial" },
{
$set: {state: "pending"},
$currentDate: {lastModified: true}
}
);
console.log("Second")
}
function settopending(f,fb)
{
console.log("First");
var t = this.transactions.findOne({ state: "initial" } , function(err, document) {//CALLBACK
update(document,f,fb , function(err, document) {//CALLBACK
console.log("Third");
applytransaction(document,f,fb);
});
});
}
function applytransaction(t,f,fb)
{
console.log("Fourth");
x=fb(t.value);
y=f(t.value);
this.model.update(
{ _id: t.source, pendingTransactions: { $ne: t._id } },
{ $inc: { bal:x }, $push: { pendingTransactions: t._id } }
);
this.model.update(
{ _id: t.destination, pendingTransactions: { $ne: t._id } },
{ $inc: { bal: y }, $push: { pendingTransactions: t._id } }
)
}
'Funktion update (Dokument, f, fb)' - erklärt es gibt keinen Rückruf Argument noch -auch genannt jeder Rückruf, 'f' und' fb' werden nie benutzt! ... akzeptiert 'this.transactions.update' einen Callback-Parameter? –