Sitelet https://web.archive.org/web/20201014225802/https://github.com/dresende/node-orm2/issues/747
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

node-orm2 or sequelize? #747

Open
jamesone opened this issue Oct 21, 2016 · 5 comments
Open

node-orm2 or sequelize? #747

jamesone opened this issue Oct 21, 2016 · 5 comments

Comments

@jamesone
Copy link

@jamesone jamesone commented Oct 21, 2016

Hey all,

Have any of you had experience using both sequelize and node-orm2? If so, which one is best? I've used sequelize quite a bit and just came across this & it looks good, really good!

@ssbrewster
Copy link

@ssbrewster ssbrewster commented Mar 21, 2017 •

@ohjames you can promisify with bluebird e.g.

const Promise = require('bluebird')
const models = Promise.promisify(require('../models'))

models('yourDb', false).then(db => doSomethingWithDb)

You might also need to set the context right e.g.

var redisGet = Promise.promisify(redisClient.get, {context: redisClient});
redisGet('foo').then(function() {
    //...
});

...but yes this is a pain and you also should really read this and then decide to use python and django instead 😄 . If you stick with node, sequelize looks good, loopback a more full featured option. I actually find orm2 useful for my purposes apart from lack of promise support.

@insidewhy
Copy link

@insidewhy insidewhy commented Mar 21, 2017

You can't promisify with bluebird though, well only partially, due to #773 and see also rafaelkaufmann/q-orm#1.

For many reasons orm2 is a terrible choice, thankfully I'm not working with the client who made me use it anymore ;) sequelize is better, I will check out loopback, but honestly I'm starting to feel that ORMs often aren't a good idea and there's plenty of recent articles by people who feel the same.

@insidewhy
Copy link

@insidewhy insidewhy commented Mar 21, 2017

Python/Django is pretty cool, used it a lot. Slightly prefer rails to Django though, much terser code due to ruby's advanced metaprogramming. Node is still cool though, despite the lack of mature ORMs, with recent projects I've been using rethinkdb without an ORM and finding there's less boilerplate when I'm just writing my joins directly.

@ssbrewster
Copy link

@ssbrewster ssbrewster commented Mar 21, 2017 •

const doSomethingAsync = Promise.promisify(db.models.my_model.create, {context: db.models}) is working fine for me in addition to the example i gave above, it can be done even if prototypes are not exposed but ok even this relies on access to methods on objects (the inconsistent API is a real problem). Thanks for reference to q-orm issue. Currently i do have to use orm2 but i'm going to raise exploring other options while the API i'm working on is still fairly contained.

Loopback is good (and worth bearing in mind it's a framework not just an ORM) but like anything there are drawbacks, context handling was an issue for me but i think they are improving that in 3.0.

I want to take a look at rethinkdb and not using ORMs is an interesting approach, I guess it depends on the ORMs available.

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

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.