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
Kenneth Lynne edited this page Jan 9, 2014
·
1 revision
Syncing is an utility method that creates all the necessary tables in the database for your models and associations to work. Tables are not replaced, they are only created if they don't exist.
There are 2 ways of syncing:
Calling Model.sync(cb) will only synchronize the model
Calling db.sync(cb) will synchronize all models
Dropping is a similar method but instead it drops all tables involved in your models, even if they were not created by ORM. There also 2 ways of dropping.
varorm=require("orm");orm.connect("....",function(err,db){varPerson=db.define("person",{name : String});varPet=db.define("pet",{name : String});db.drop(function(){// dropped all tables from defined models (Person and Pet)Person.sync(function(){// created tables for Person model});});});