EvanBurchard / barnacle

Easier query interface for sails console
6 stars 1 forks source link

What is it?

Barnacle makes working with sails console easier

Is it that hard?

Sails console is difficult to work with compared to something like rails console.

Compare this:

User.find

To this:

User.find({}, function(err, users){console.log(users)})

One is significantly less typing (and errors in typing) (and accidentally hitting the down key and having to retype everything).

Can I use it in production code?

NO. Don't do that. This doesn't actually flip the paradigm of the continuation passing/promise style of writing. It does not magically make Waterline synchronous or anything like that. This is good for when you're on the console, and you want quick action, quick feedback, and less typing.

Benefits

Limitations

Example Usage

(from sails console)
Barnacle = require('Barnacle');
Barnacle.modelNames = ['AdminInvite', 'Comment', 'Project', 'Subscriber', 'User'];
Barnacle.defineMethods();
User.find_();

Now you can use dynamic and static methods without specifying callbacks.

Methods Added

Todo: