mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-28 05:37:34 +03:00
19 lines
480 B
JavaScript
19 lines
480 B
JavaScript
|
const searchPlugin = function searchPlugin(Bookshelf) {
|
||
|
const Model = Bookshelf.Model.extend({
|
||
|
// override this on the model itself
|
||
|
searchQuery() {},
|
||
|
|
||
|
applySearchQuery: function applySearchQuery(options) {
|
||
|
if (options.search) {
|
||
|
this.query((qb) => {
|
||
|
this.searchQuery(qb, options.search);
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
|
||
|
Bookshelf.Model = Model;
|
||
|
};
|
||
|
|
||
|
module.exports = searchPlugin;
|