mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-24 23:48:13 -05:00
Improved JSDoc typing for Bookshelf plugins
no issue - eager-load: turned param import into typedef for reusability and fixed attribute typing - pagination: - removed typing on helper function object - this was incorrect and tsserver can pick up the real types a lot better, so removing it reduces maintenance overhead - `fetchPage` actually returns a Promise, so this fixes the typing on the docs
This commit is contained in:
parent
becf4c04e5
commit
b7d96149e2
2 changed files with 6 additions and 5 deletions
|
@ -5,7 +5,7 @@ const debug = _debug('ghost-query');
|
|||
/**
|
||||
* Enchances knex query builder with a join to relation configured in
|
||||
*
|
||||
* @param {Bookshelf.Model} model instance of Bookshelf model
|
||||
* @param {Bookshelf['Model']} model instance of Bookshelf model
|
||||
* @param {String[]} relationsToLoad relations to be included in joins
|
||||
*/
|
||||
function withEager(model, relationsToLoad) {
|
||||
|
@ -46,8 +46,6 @@ function load(options) {
|
|||
* Extends `bookshelf.Model` native `fetch` and `fetchAll` methods with
|
||||
* a join to "eager loaded" relation. An exaple of such loading is when
|
||||
* there is a need to order by fields in the related table.
|
||||
*
|
||||
* @param {import('bookshelf')} Bookshelf
|
||||
*/
|
||||
module.exports = function eagerLoadPlugin(Bookshelf) {
|
||||
const modelPrototype = Bookshelf.Model.prototype;
|
||||
|
@ -78,3 +76,7 @@ module.exports = function eagerLoadPlugin(Bookshelf) {
|
|||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* @typedef {import('bookshelf')} Bookshelf
|
||||
*/
|
||||
|
|
|
@ -30,7 +30,6 @@ defaults = {
|
|||
/**
|
||||
* ## Pagination Utils
|
||||
* @api private
|
||||
* @type {{parseOptions: Function, query: Function, formatResponse: Function}}
|
||||
*/
|
||||
paginationUtils = {
|
||||
/**
|
||||
|
@ -164,7 +163,7 @@ const pagination = function pagination(bookshelf) {
|
|||
* 2. the actualy fetch query with limit and page property
|
||||
*
|
||||
* @param {options} options
|
||||
* @returns {paginatedResult} set of results + pagination metadata
|
||||
* @returns {Promise<paginatedResult>} set of results + pagination metadata
|
||||
*/
|
||||
fetchPage: function fetchPage(options) {
|
||||
// Setup pagination options
|
||||
|
|
Loading…
Add table
Reference in a new issue