You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After [connecting](Connecting to Database), you can use the connection object (db) to define your models. You need to specify the name of the model, a specification of the properties and options (optional). Here's a small example:
The model is called person (which is usually the name of the table in the database), it has 3 properties (name and surname as text and age as number). The second object passed is the options. In this example there is a model method called fullName. Here's an example of the usage of this model:
Person.get(73,function(err,person){if(err)throwerr;console.log("Hi, my name is %s",person.fullName());});
This would get person with id=73 and print it's name and surname.
There are other types of [properties available](Model Properties).