Open vellotis opened 8 years ago
@vellotis this looks interesting - sorry for the delay, will take a look tomorrow
@bsiddiqui There is one thing that bookshelf-fields plugin uses the same method name 'field'. Maybe it would be better to name them different. Or event make them accessible through a property?
function QueryHelper(model) {
this.context = model;
}
QueryHelper.prototype.field = function () {
return bookshelf.knex.raw(
"`" + this.context.prototype.tableName + "`." + formatFieldName( fieldName )
);
};
// and alias declaration
var SomeModel = Model.extend({
qh: function () {
return new QueryHelper(this);
}
});
SomeMode.query(function (query) {
var qh = this.qh();
query.where(this.qh().field('field_name', '=', true);
}).fetch();
// etc
I am a fan of this library. :+1: And just may have a neat suggestion for additional functionality.
I am using some neat methods that have easened where and join queries.
Add to Model static methods...
Example of usage (in CoffeeScript):
In case this is not a case of discussion be free to close the issue. I would contribute for PR.