0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-10 23:36:14 -05:00
ghost/core/server/models/plugins/custom-query.js
Daniel Lockyer 0cd9acabec
Imported Bookshelf type into plugin JSDocs
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
2021-06-14 16:30:58 +01:00

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;