I'm quite new to NodeJs but I was used to work with ORMs with PHP. Each time I deployed the site I did a sync to the database. Ex doctrine:schema:update --force when in Symfony.
However, in the documentation of Sequelize, they give examples where the sync is being done before each of the queries. Is this a good practice?
I just made a test and it's possible to make queries without the sync so I was wondering if it's a good idea make the sync only once when the application is launched. How do NodeJs developers are used to work?
In this example, I can do both:
User.sync().then(function () {
return User.create({
firstName: 'John',
lastName: 'Hancock',
locale: 'en'
});
});
User.create({
firstName: 'John',
lastName: 'Hancock',
locale: 'en'
});
The difference is that in the second case I'm not in a promise chain so I can't do a task that depends on the user creation without creating a promise on my own.
Thanks ;)
via unadivadantan
No comments:
Post a Comment