In meiner Loopback-Anwendung, ich bin mit mongodb als meinen Backendnach dem Update attrubutes Endlosschleife
betrachten ich habe 2 Sammlungen wie A, B. Ihre Beziehung ist . Also in meinem aftersave
Haken des Modells A Ich habe
if(isNewInstance) {
// When creating A i have to compute data
// and create a document in B and have to update the _id of B to A
// For Updating i am calling:
ctx.instances.updateAttributes();// this will once again call this
//after save hook and with isNewInstance == false,
// so it will go in else condition also.
} else {
// When Updating A i have to compute data and create a document in B
// and have to update the _id of B to A
}
**Summary**
: SO, wenn eine neue Instanz von A zu schaffen auslöst zweimal wegen updateAttributes, wie kann ich einschränken, dass, wie wenn die Instanz der Bearbeitung nennen sollte, aber nicht beim Aufruf von updateAttributes .. Bitte teilen Sie Ihre Ideen. Danke im Voraus ..
Was möchten Sie auf 'A' und' B' während des 'AfterSave'-Hooks machen? – Overdrivr
@Overdrivr Danke .. In AfterSave von A berechne ich ein JSON und erzeuge ein Dokument in B (welches _id hat). Ich muss diese _id auf einen Schlüssel in A aktualisieren. – Subburaj
Also im Grunde erstellen Sie eine Instanz von "B" und verknüpfen Sie es mit der aktuellen Instanz von "A". Ist das richtig ? – Overdrivr