-
Notifications
You must be signed in to change notification settings - Fork 23
Create new instance function #1
Comments
You can create a new model instance by invoking the below. This also inserts the model in the datastore. models.User.create({
name: 'Arjan'
}); If you want to retrieve any existing model instances, you can use e.g.: models.User.findOne({
name: 'Arjan'
}); Is this what you mean? |
Almost, I mean more like this models.User.new().then(function(user) { etc.... |
I see. Without actually inserting the user in the datastore, I assume? |
Yes that's correct. It's just convenience.... |
A similar idea is something like: var user = new models.User();
user.name = 'Arjan';
user.save(); What do you think of that? |
Yes I agree that's more elegant. |
How's the reading going and did you see the latest features? |
I like those new features. Especially sockets. I've to figure out the new sources yet. I've also setup a test project to try some of the features. thx |
In The below creates a var pie = PieModel.new();
pie.type = 'Apple';
pie.save()
|
Request:
It would be great if there was a function that create an instance of a model including including all the properties with default values, calculated fields aso.
(maybe such a function is already there?)
ps. I'm studying on the code at the moment...
The text was updated successfully, but these errors were encountered: