db.load vs orm.express
See original GitHub issueI have a single models.js module that I’d like to load in both Express request handlers and non-Express code. It would be nice if the function definitions for these two cases could be similar so that the models.exports function could be written once well.
Express expects a function with db and models as an argument:
define: function (db, models) {
models.person = db.define("person", { ... });
}
On the other hand, db.load wants to pass just a callback:
db.load("./models", function (err) {
// loaded!
var Person = db.models.person;
var Pet = db.models.pet;
});
Issue Analytics
- State:
- Created 10 years ago
- Comments:9 (3 by maintainers)
Top Results From Across the Web
Learn all about Different ORM in Node JS || 2021 - Medium
ORMs provide the concept of Database Abstraction which makes switching databases easier and creates a consistent code base for your application.
Read more >Node.js ORMs: Why you shouldn't use them - LogRocket Blog
ORM is a powerful tool, but it adds a layer of complexity that can cause some hiccups. Here's why you may want to...
Read more >Understanding Node.js Sequelize ORM Models - Section.io
This article will help you understand Sequelize models, from model definition to model usage. Sequelize works with all the SQL-based databases. ...
Read more >The Ultimate Guide To Get Started With Sequelize ORM
Sequelize is a popular ORM for Node.js which allows managing the SQL databases easily. It supports various databases like — Postgres, MySQL, ...
Read more >Top 11 Node.js ORMs, query builders & database libraries in ...
Choosing an ORM or query builder for your Node.js app can be daunting. ... Eager and Lazy loading of relations; Synchronizing database based ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I just want to share my solution:
File stack.js
File model.js
This will pass to the readme or the wiki as soon as we release a new version.