mphasize/sails-generate-ember-blueprints

Associations between models

Closed this issue · 2 comments

Hello,

first, thank you for these blueprints!

These sails-generate-ember-blueprints do not contain the "add" function in contrast to the original sails blueprints (http://sailsjs.org/documentation/reference/waterline-orm/populated-values/add).

We have two basic use cases:

  • via ember.js
  • in sails-only "scripts", like an initial data importer that needs to establish multiple associations while creating records.

For these 2 high level use cases, how are associations intended to be used via sails-generate-ember-blueprints, for

  • one-to-one
  • one-to-many and
  • many-to-many associations?

Should we just the add the "add" function of the original sails blueprints?

Thank you very much,
Manuel

Hi Manuel, Ember Data used to send relationships as complete arrays and at least in my testing would never actually use the add/remove endpoints. That's why I removed them, but feel free to add.

But I have to say, that the current blueprints are not up to date with the latest developments. As far as I know, the recommended Ember way for 2+ is to go fully JSON API. The blueprints in their current form are still intended for the Ember Data RESTAdapter from <= 1.13. Cheers

Manuel,

If you are still interested in gaining add support:

Via a pull request,
Could you drop an add.js action here:
https://github.com/mdconaway/sails-ember-rest/tree/master/templates/actions

and then simply reference that action here:
https://github.com/mdconaway/sails-ember-rest/blob/master/templates/controllers/EmberController.js

Additionally, in the new repo, there is a concept of "interrupts" which allows you to do complex things like create historical tracking objects, etc, within the context of the controller before a response is sent to the client. If you would like to implement an interruptor pattern in the new add action, feel free to follow the interruptor patter in the other actions, or I could bolt it on after your pull request.

Thanks!