Is there an update API for epicenter.js data service?

How to I update a document with data service?

I see REST Data API has a PUT method can do update. Can I access that API through data service?

How to mix epicenter API with REST API?

Hi,

Yes, Epicenter.js includes a data service, which is built on top of the REST Data API.

There is some documentation on the data service here: https://forio.com/epicenter/docs/public/api_adapters/generated/data-api-service/

There is also a more detailed example that uses the data service here:
https://forio.com/epicenter/docs/public/how_to/leaderboard/

Hope this helps!

Thank you! I am already using the epicenter.js data service. I don’t see ‘update’ feature there, I can only save, each save would create a new document with new id. I wonder how to update an existing document with it. I notice REST API has update feature, but don’t want to go that way if don’t have to.

I hope epicenter.js would wrap more the features that currently only provided by REST API

Jay

The data service .save() creates a new document. But the .saveAs() function uses the REST Data API’s “PUT”. For example:

ds.saveAs('myDocument', { 'myData': 2 });
...
ds.saveAs('myDocument', {'myData': 10});

does not create a second document, it updates the myDocument/myData field to be 10.