ember.js - How to store and load models from Ember data to and from local files? -


i'm giving go @ making ember electron app , wanting save model data json or json-api formatted file instead of pushing remote api, best way this?

i see possible call .tojson() on model objects basic json representation of model, can save disk using electron-settings, i'm @ loss on how load data in.

from can see, using "push" function in ember data allows import data, seems expects json-api format instead:

https://guides.emberjs.com/v2.9.0/models/pushing-records-into-the-store/

i've found easiest store data in json api spec format. out of system call var data = model.serialize({includeid: true}) give json api specced version of data.

or load of models:

var jsonmodels = []; allmodels.foreach(function(model) {     jsonmodels.pushobject(model.serialize({includeid: true}).data) }, this); return {data: json.stringify(jsonmodels)}; 

you can call this.get('store').pushpayload(data); load json store.


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -