I’m using SequelSphere to store data for a webapp, and I’m using change trackers to track the changes. The first time I sync, the tracker returns the changed rows. The second time I sync, the tracker returns both the first and second set of changed rows. Here is what I’m doing:
// create my tracker
var tracker = db.changeTrackers.create("order_tracker", ["orders"]);
// insert first set of orders
for (var i = 0; i < firstOrders; ++i)
db.insertRow("orders", firstOrders[i]);
// sync orders up
performSync(db.changeTrackers.get("order_tracker").getChangedRows());
// insert more orders (second set)
for (var i = 0; i < secondOrders; ++i)
db.insertRow("orders", secondOrders[i]);
// sync second set of orders up
performSync(db.changeTrackers.get("order_tracker").getChangedRows());
The first sync works fine. The second sync is sending up all the orders from the first set and the second. I only want it to return the second set. How can I get it to return just the second set?
Look here for the API for a DBChangeTracker: SequelSphere API
There are actually two ways to answer your question:
1) Use the “clearChanges()” method to remove all of the changes from your DBChangeTracker. You can do it “logically” right after the sync:
2) If the data synchronization occurrs asynchronously, end the tracking and use a second change tracker to hold the new changes:
Let me know if this is sufficient!