0

We have a web2py application that we want to connect to an EmberJS client. The idea is to use the responsive capabilities of EmberJS to keep the client updated writing minimal code.

We have (REST) primitives which are in charge of creating / updating the underlying datastore (CouchDB). These primitives are sometimes complex and covering corner cases, involving the creation of several documents, connecting them, validating configuration parameters, ... This is implemented in the backend. We would like to avoid duplicating the full modelling of the data in our EmberJS application, and avoid duplicating the logic implemented by those primitives.

I have some questions:

  • does it make sense in EmberJS to just model a subset of the data in the documents? We would just create models for the small amount of properties that the user is able to interact with. The client would not see the full CouchDB documents, just the data necessary for display / interaction.
  • is it possible to connect EmberJS to a REST interface, without having to fully model the underlying data in the database?
blueFast
  • 33,335
  • 48
  • 165
  • 292

1 Answers1

3

does it make sense in EmberJS to just model a subset of the data in the documents?

Yes. There is no need to create ember models for objects/properties that user will not need to interact with.

is it possible to connect EmberJS to a REST interface, without having to fully model the underlying data in the database?

Definitely that is possible, it's a fairly common use case. The best way to get started is by building a small MVP that works with just couple of models. Once you've got that wired up it will be easy to add more domain objects.

The tricky part (especially at first) will be mapping your rest endpoints to the ember-data REST adapter. The adapter will work out-of-box with some REST endpoints - see the REST Adapter - but connecting a CouchDB datastore will probably require some customization. The tools for this are still evolving, have a look at ember-data integration tests to see what is available.

Mike Grassotti
  • 19,010
  • 3
  • 57
  • 57
  • I'd write a full-blown question, but I'd be worried about not getting enough traffic. Can you or @jeckyll2hide give me any information about making Ember connect from it's server-side to a RESTful service? As far as I can tell, a lot of the docs / discussion I've seen provide insight into configuring essentially a cross-origin setup where the user's browser hits `host:port/ember` and `host:port/rest` . Ember already has a server-side, so why not configure it to hit `host:port/rest` for loading data? – blong Jun 04 '15 at 17:42
  • ***EDIT***: I wrote a full-blown question: http://stackoverflow.com/questions/30651223/configure-embers-back-end-to-communicate-with-a-restful-service – blong Jun 04 '15 at 18:18