mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-23 02:41:50 +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;
|