mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-10 23:36:14 -05:00
no issue - the `Bookshelf` type wasn't being imported anywhere and editors were showing warnings for the missing type - also fixes use of `Bookshelf.Model` - this doesn't work if we declare `Bookshelf` using a `@typedef` and the preferred syntax is using an array index - note: it still complains because we're calling functions that are only declared in our custom Bookshelf Model but this is a step in the right direction
19 lines
472 B
JavaScript
19 lines
472 B
JavaScript
/**
|
|
* @param {import('bookshelf')} Bookshelf
|
|
*/
|
|
const customQueryPlug = function customQueryPlug(Bookshelf) {
|
|
const Model = Bookshelf.Model.extend({
|
|
// override this on the model itself
|
|
customQuery() {},
|
|
|
|
applyCustomQuery: function applyCustomQuery(options) {
|
|
this.query((qb) => {
|
|
this.customQuery(qb, options);
|
|
});
|
|
}
|
|
});
|
|
|
|
Bookshelf.Model = Model;
|
|
};
|
|
|
|
module.exports = customQueryPlug;
|