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.
Rdb – a Node.js ORM with transactions, persistence ignorance and promises
31–40 of 47 posts
Re: Rdb – a Node.js ORM with transactions, persistence ignorance and promises
#32Earlier 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…
- 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
#33Earlier 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).
Re: Rdb – a Node.js ORM with transactions, persistence ignorance and promises
#34Earlier 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?
Re: Rdb – a Node.js ORM with transactions, persistence ignorance and promises
#35Not sure I see the advantage over waterline ( https://www.npmjs.com/package/waterline ) ?
Re: Rdb – a Node.js ORM with transactions, persistence ignorance and promises
#36Earlier 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.
Re: Rdb – a Node.js ORM with transactions, persistence ignorance and promises
#37Earlier 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.
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
#38I'm currently checking out ORMs for node.
What I found was Bookshelf, Sequelize and Jugglingdb.
I think Rdb needs SQLite support for development purposes and smaller projects.
Re: Rdb – a Node.js ORM with transactions, persistence ignorance and promises
#39Nice. I'm currently checking out ORMs for node. What I found was Bookshelf, Sequelize and Jugglingdb. I think Rdb needs SQLite support for development purposes and smaller projects.
Re: Rdb – a Node.js ORM with transactions, persistence ignorance and promises
#40Earlier 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?