Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why export Sequelize? #69

Closed
psaeuerl opened this issue Aug 11, 2017 · 3 comments
Closed

Why export Sequelize? #69

psaeuerl opened this issue Aug 11, 2017 · 3 comments

Comments

@psaeuerl
Copy link

psaeuerl commented Aug 11, 2017

I currently do not understand why Sequelize is exported in ./models/index.cs

db.Sequelize = Sequelize;

module.exports = db;

I do not see it used anywhere and from my current understanding, i do not know why it is exported here.
PS: I´m quite new to sequelize and i´m trying to understand the sample.

Thanks in advance

@sushantdhiman
Copy link
Contributor

You can get static methods like literal, and, fn etc which will be used when building queries, It also expose errors which can be accessed like db.Sequelize.UniqueConstraintError to catch errors

@psaeuerl
Copy link
Author

Ahh thank you, this makes sense.
So it is basically best-practice (if only one database is used) to export sequelize with it.
Is the statement above valid?

@sushantdhiman
Copy link
Contributor

If you need those methods or errors you can get them from model.sequelize.Sequelize.fn etc but thats too long for some guys. So its just a way to easily access required methods / errors

Its all up to you how you want to access it, shorter simpler way is better I guess

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants