Generate a snapshot from a model

Hi all, I was just wondering if anyone knew any method on the public API to generate a snapshot from a model?

The use-case I had in mind was generating id’s for models client-side, and enqueueing any saves which should be done, and processing this queue in the background. This process would pause temporarily in the event of the server not being available (allowing the user to continue working offline for the most part), or an error occurring when saving the current entity being processed.

The reason I would need the snapshot is in the event of the same entity being saved multiple times at different points in time before the queue gets processed. Because other models could depend on the changes from that entity, I would need to rollback the store state to that point in time (replacing / removing all current instances of entities in the store up until that specific operation), and run the save logic from that point forward and deal with errors as i get to them.

I could also store these snapshots in local-storage in case of the browser closing etc…

Anyone have any thoughts on this? I suppose what I could do for now if no-one has a better way of doing this I could reopen DS.Snapshot and add a public method for creating one.

Just brainstorming, but I could also just use DS.Store.serialize() and DS.Store.pushPayload to achieve the same thing rather than exposing the snapshot functionality.

Ember-Pouch can perhaps help you. You can setup a CouchDB server and let it sync to your backend. Than use Pouch to connect to Couch. Examples:

Myapp Source: GitHub - broerse/ember-cli-blog: Tom Dale's blog example updated for the Ember CLI

We use it in a space where we lose WiFi and it Syncs perfectly when we walk back to where we have WiFi.

Awesome thanks, i’ll take a look :smile: