Closed appdevdesigns closed 5 years ago
does this help? https://github.com/balderdashy/waterline/issues/481
Brilliant!
Adding autoIncrement:true
to the primary key definition now returns the value to the instance returned from .create()
. And everything works fine.
I guess it makes sense if I think about it. But I agree with you, there needs to be some more documentation on how to migrate existing tables into sails. Or at least a 'things to watch out for' section on the documentation page.
Thanks for answering this one!
I've defined the following 2 models in a 1-Many fashion:
and
Now I'm trying to populate the two models using the following routine:
When I run this adding data to the function(), I get the following output:
Notice that there is no, ren_id returned on the personObj from the create().exec() methods.
however, if I change the routine to immediately lookup the person from the create() routine like this:
I now get the following output:
And everything works as expected.
It seems that on the .create() method, the custom primary key isn't being set, and the resulting modelInstance isn't able to properly .save() it's data.
Is this the expected behavior?