gritzko/swarm

Reconstitute model from static data

Closed this issue · 1 comments

Question. I'm on 0.3.25. In a certain case I have the oplogs as JSON like it is stored by filestorage (_version, _tail with oplogs). I want to hydrate my model with that data, not using Host or storage, how can I do that?

this.spec = new Swarm.Spec('/MyModel#44Gmj+some_id');
this.typeid = this.spec.filter('/#');
let Mr = new MyModel(this.typeid);
// then what?

How do I apply the tail of ops to get a current model?

Maybe I'm trying to do something stupid. Just trying to understand how things work, and thought there would be a shortcut. Decided to roll my own read-only storage that serves the model the usual way via host.get().

It confuses me that I have to reset _version in my saved state or I will get replay warnings and the model wont hydrate, but I can live with that.