dimanche 18 mars 2018

Send additional data in model.save to sails js model

I'm working with ember js and sails js, now i have a little issue

i have a save function that stores data using model.save() and i want to

send some data along with the model.save() method to the sails js model

and receive it there in the afterCreate method

my ember js controller

save(model, invoice) {
    model.save().then(() => {
    this.get('modalManager').remove(this.get('modal'))
})

my sails js model

afterCreate : function(data, cb) {
    /* I Want to get the invoice object from the Ember controller 
    and do something like */
    Invoice.create({ visit : data.id, paid : 'Amount Set in the invoice Object })
}

How can i send the invoice object to the model ? i tried passing it in the save parameters like model.save(invoice) and logged 3 parameters in the afterCreate method like function(data, invoice, cb) but i got the model itself, the callback and undefined

Help me in this please.




Aucun commentaire:

Enregistrer un commentaire