Question: check for unsaved changes in session
Closed this issue · 1 comments
drakhart commented
This is just a question, not a real issue: while using this library I came up with the idea of calling session.saveChanges()
automatically before sending the server response (we're talking API here) whenever the session has unsaved/pending changes, but I couldn't find any way for checking for this (I inspected some session
objects at different stages).
So, is there any publicly accessible way to check if a session has currently unsaved changes?
ayende commented
const newSession = store.openSession();
const basicName = new BasicName();
basicName.name = "Toli";
await newSession.store(basicName, "users/1");
assert.strictEqual(Object.keys(newSession.advanced.whatChanged()).length, 1);
await newSession.saveChanges();