How do you create an adapter that only saves to the store but not server

I would like to create a specific model adapter that only pushes records into the in memory store but does NOT actually try to POST to backend server.

What hooks do I need to override? Anybody know an example that does something like this?

Using Ember Data 1.13.3

After the record is created I was hoping to use

store.peekAll('my-model') 

to get the contents of the store.

store.createRecord('modelName')

push it on client store ? it will only be posted to server when modelName.save() is called ?

Not sure why you need an adapter for this. An easier path might be to just call store.push() instead of store.createRecord(). store.push() adds the model to your local cache. We’ve used this method extensively for a websocket connection so the server can push updates to our client.

Thanks.

I have an application that has no persistence by design. There is a simple python script that supports some very specific GET requests but cannot receive any PUT, POST, or inbound data. Any attempt to save a record will crash. So just wanted to make sure I understood all the cases where an ajax request to backend is actually triggered.

It looks like just doing createRecord('model-name') and never saving does the trick.

Just needed to understand which methods I could use that allowed me to only work with the store and not break my read only backend.

I guess if you really wanted you could also extend the adapter and override updateRecord, createRecord and deleteRecord to be no-ops (not tested, but I suppose it would work).

1 Like

The Fixture adapter did this, but it got removed. Maybe there’s an addon that puts it back.