Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a new instance of waterline model without saving it

This might be a very simple question but I don't find anything about it in the Waterline docs.

How is it possible to get an instance of a Waterline model without immediately saving it.

Model.create(data); // already written to database

I am looking for something like

var user = User.new(data); // new instance, not persistent so far
user.doSomething(withThis); // call method on instance
user.save(); // Now write it to database

Thanks

like image 589
Ole Spaarmann Avatar asked Jun 18 '15 21:06

Ole Spaarmann


1 Answers

Looks like you can utilize basic javascript instantiation. Check out this issue not sure if it has been fixed but you can follow the crumbs from there.

https://github.com/balderdashy/waterline/issues/763

like image 126
Brad Decker Avatar answered Oct 11 '22 12:10

Brad Decker