Live data from Hacker News

Rdb – a Node.js ORM with transactions, persistence ignorance and promises

npmjs.com

41–47 of 47 posts

Re: Rdb – a Node.js ORM with transactions, persistence ignorance and promises

#41

Is anyone working on auto-generated migrations in node.js ala. Django / South?

I believe Sequelize does this: https://sequelize.readthedocs.org/en/latest/docs/migrations/

No it does not do this yet. See this issue [1]. The db:create task in the sequelize cli only creates a new stub migration file.

1 - https://github.com/sequelize/cli/issues/8

Re: Rdb – a Node.js ORM with transactions, persistence ignorance and promises

#42
post #40
post #37

Earlier quoted context omitted.

Sequelize has the build method, which persists automatically. Couldn't the rest be achieved by simply adding a few (update, delete) methods to the model classes?

The create method on model's persist automatically. Build just creates an instance without saving it to the database.

Really? I thought it was the other way around...

Re: Rdb – a Node.js ORM with transactions, persistence ignorance and promises

#43
post #24

Any chance Rdb plans to support a traditional callback style interface for those of us that prefer to stay away from promises?

My plan was to stick to promises only. Unless there are lots of lots of developers that really wants callbacks.

please stick with promises. Promises are the only sane way to deal with async in JS. With people starting to use async/await they become even more compelling.

The people who defend callbacks either don't understand the benefits that promises provide, don't know about async/await or are suffering from stockholm syndrome.

Callbacks do not pass the reversibility test. If everyone had started out with promises and / or async/await, and someone proposed callbacks as a way to deal with this instead, they'd be dismissed as a fool. They're an accident of history and we should forget about them as quickly as possible.

Re: Rdb – a Node.js ORM with transactions, persistence ignorance and promises

#44
post #43
post #24

Earlier quoted context omitted.

My plan was to stick to promises only. Unless there are lots of lots of developers that really wants callbacks.

please stick with promises. Promises are the only sane way to deal with async in JS. With people starting to use async/await they become even more compelling. The people who defend callbacks either don't understand the benefits that promises provide, don't know about async/await or are suffering from stockholm syndrome. Callbacks do not pass the reversibility test. If everyone had started out with promises and / or a…

Callbacks allow await/defer in Iced CoffeeScript, not to mention the other async libs as stated above.

Promises don't really offer any benefit to program structure overall, generally devs just end up creating long chains of anonymous functions rather than long nests of anonymous functions. Promises actually discourage flat code (and functional programming) for that reason. I understand they seem attractive but become a hack in complex situations.

Re: Rdb – a Node.js ORM with transactions, persistence ignorance and promises

#45
post #2

Seems interesting ! I would definitely like more ORM for node.js technologies. The concurrent are Sequelize ( http://sequelizejs.com/ ) and Bookshelf ( http://bookshelfjs.org/ ), both very mature libraries (look at the Sequelize test suite, it's quite impressing !). Iroal, any comment on the rdb choices against these two big guys ? How can we expect rdb to evolve ?

Great question. To me what Node is missing most is a ORM that isn't tied to a backend -- relationships can easily be expressed without needing to know whether data is fetched through an API or through SQL. This is how ORM is often done in frontend JS. We're working on and using such a backend-agnostic Node lib, but I don't think it's polished enough for release yet.

Re: Rdb – a Node.js ORM with transactions, persistence ignorance and promises

#46
post #43

Earlier quoted context omitted.

please stick with promises. Promises are the only sane way to deal with async in JS. With people starting to use async/await they become even more compelling. The people who defend callbacks either don't understand the benefits that promises provide, don't know about async/await or are suffering from stockholm syndrome. Callbacks do not pass the reversibility test. If everyone had started out with promises and / or a…

Callbacks allow await/defer in Iced CoffeeScript, not to mention the other async libs as stated above. Promises don't really offer any benefit to program structure overall, generally devs just end up creating long chains of anonymous functions rather than long nests of anonymous functions. Promises actually discourage flat code (and functional programming) for that reason. I understand they seem attractive but become…

> Callbacks allow await/defer in Iced CoffeeScript

Not the same thing as in ES6, also that project is totally dead.

> generally devs just end up creating long chains of anonymous functions rather than long nests of anonymous functions

Not true in my experience, also not required at all when using async / await.

> Promises actually discourage flat code (and functional programming) for that reason.

This is really not true, Promises are functional and composable, callbacks are imperative.

> I understand they seem attractive but become a hack in complex situations.

Just no. Callbacks lead to terrible "solutions" like caolan/async, callbacks make refactoring extremely awkward.

Callbacks don't even get to claim better performance, because they require a load of internal hacks in node/io.js to maintain state.

With async/await in the picture, callbacks so totally inferior I can't believe someone would attempt to argue otherwise.

Re: Rdb – a Node.js ORM with transactions, persistence ignorance and promises

#47
post #4
post #2

Seems interesting ! I would definitely like more ORM for node.js technologies. The concurrent are Sequelize ( http://sequelizejs.com/ ) and Bookshelf ( http://bookshelfjs.org/ ), both very mature libraries (look at the Sequelize test suite, it's quite impressing !). Iroal, any comment on the rdb choices against these two big guys ? How can we expect rdb to evolve ?

And if you just want a flexible ORM without models, knex ( http://knexjs.org/ ), which bookshelf uses. I found knex + Postgres to be a great combination.

I personally wouldn't consider Knex an ORM. I'd describe it more as:

A cohesive set of functions that help you build and execute SQL operations.

Post reply on HN