bookshelf-modelbase icon indicating copy to clipboard operation
bookshelf-modelbase copied to clipboard

findAll: format attributes filter

Open chentsulin opened this issue 5 years ago • 2 comments

.forge() enables case-converter(https://github.com/bookshelf/bookshelf/blob/master/lib/plugins/case-converter.js), but .where() does not do case convert like forge().

https://github.com/bookshelf/bookshelf/blob/b6abda9486b3f06d1ee58aff063c14836f0a2e1d/lib/model.js#L1317-L1319

(.where just call .where on query builder)

We should let findAll and findOne have the same case converting behavior

chentsulin avatar Sep 20 '18 03:09 chentsulin

That makes sense. It'll be a breaking change so I'll need work it into a major relase

bsiddiqui avatar Sep 20 '18 22:09 bsiddiqui

I found that this is not working:

this.forge(extend({}, filter)).fetchAll(options);

(got select command with no where condition)

But this works:

const model = this.forge();
return model.where(model.format(extend({}, filter))).fetchAll(options)

Just format attributes for where.

chentsulin avatar Sep 21 '18 04:09 chentsulin