nicola/node-imessage

Implement knex and Promise API

bendrucker opened this issue · 4 comments

Cool project @nicola. I'm coming here from HN. Wanted to propose two related changes and see what you thought before taking the time for a PR:

  1. Use knex instead of raw SQL
  2. Use a fully promise oriented API with Bluebird and then use nodeify to call callbacks if provided

Re: 1, I'm a maintainer over at knex. It's a query builder that support SQLite as well as well as almost every other popular SQL database. Aside from cleaning up the source code and making it more readable, knex would make it a whole lot easier to do your "ideally" section at some point and allow the user to mutate the builder.

Re: 2, the API would remain backwards compatible but all methods would also return promises so they're a lot easier to compose.

hey @bendrucker,

  1. really great work on knex. I will have a look at that soon
  2. I was considering using bluebird, but I will probably use Promise in ES6

Re1) Oh great! I hope the ideally solution will work fine soon then. Feel free to send a PR.
Re2) OK

ES6 Promises are nice but are:

  1. Slower than BB
  2. Have fewer features
  3. (Most importantly) depend on an ES6 runtime which some people won't have

I'll write up a PR for this stuff

👍

Happy to revisit this if you intend to continuing build this lib. I'm doing some issue cleanup and am going to close this and #3.