Live data from Hacker News

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

npmjs.com

31–40 of 47 posts

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

#31
post #28

Earlier quoted context omitted.

Both callbacks and promises are fairly simple interfaces for calling a function after some other function has completed. Both interfaces can be abused to give you an ever growing indent and give the appearance of "callback hell" Both interfaces can be use elegantly to help you reason about your code, make it easy to follow, and handle errors centrally. Only one is supported natively by node.js and is the standard asy…

Oh ok, was just wondering about your reasons and that clears things up. That's a good read as well. But I think promises give you a way to compose them in a way that callbacks don't. With promises you can call easily call a function when multiple promises are fulfilled.

[deleted]

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

#32
post #28

Earlier quoted context omitted.

Oh ok, was just wondering about your reasons and that clears things up. That's a good read as well. But I think promises give you a way to compose them in a way that callbacks don't. With promises you can call easily call a function when multiple promises are fulfilled.

Actually would argue that Promises are less composable since you're forced to use whatever control flow paradigm the Promise library has provided or add another library to handle control flow. By utilizing callbacks, you are free to use Async.js[0] or Step.js[1] to solve the problem you described. These libraries are great since they give you control over parallel vs series execution of the pre-requisite functions as…

At least a part of promises, the then function, is standardized through Promises/A+. This way you can easily combine different promise libraries to do things like:

- sequential execution

- parallel execution and wait for all of them to finish

- automated error handling

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

#33
post #7

Earlier quoted context omitted.

Neither Sequelize nor Bookshelf has persistence ignorance as far as i know.

Ok, after a lookup, "persistence ignorance" is the ability to have implicit save of the models when things change. Bookshelf has events, which make very easy to wire some kind of persistence ignorance (we implement it in our base Model class).

I would expect those events to be triggered by action though, then it wouldn't be persistence ignorance.

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

#34
post #12

Earlier quoted context omitted.

Not everyone is only using Mongo with Node

Good point and I just checked: rdb seems to be for SQL based DBs. But I am wondering who is using SQL based DBs with Node, feels ancient to me, except you build the next datastore for a bank but even then. Also Postgres with its JSON options does not give the feeling, flexibility and speed as Node/Mongo. I could imagine that the larger part of Node users are working with Mongo, or not?

Have you tried JSONB and can you expand on how it does not give you speed and flexibility?

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

#36
post #16

Earlier quoted context omitted.

I really really really like Knex. While Mongo claims to be "easy" and "js-native", It's far easier doing complicated queries with Knex on Postgres than on Mongo with the official client. I work on a mongo project and doing aggregate queries is really ugly and painful. Everyone praising mongo probably never made "advanced" queries like that or dismissed SQL as shitty and unsecure without ever using it.

What would be 'unsecure' about SQL? Not sure I ever heard that argument before.

unparamatarized queries are the usual issue, so not an issue with sql as much as how people misuse sql.

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

#37
post #7

Earlier quoted context omitted.

Ok, after a lookup, "persistence ignorance" is the ability to have implicit save of the models when things change. Bookshelf has events, which make very easy to wire some kind of persistence ignorance (we implement it in our base Model class).

I would expect those events to be triggered by action though, then it wouldn't be persistence ignorance.

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?

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

#40
post #37

Earlier quoted context omitted.

I would expect those events to be triggered by action though, then it wouldn't be persistence ignorance.

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.
Post reply on HN