-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
164796899-feature: pagination support for articles
- modify getAllArticles controller - write integration tests - add middlewares [Delivers #164796899]
- Loading branch information
1 parent
3cfe8a5
commit 29f65e3
Showing
7 changed files
with
122 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,25 @@ | ||
/** | ||
* @name findById | ||
* @description This is function for getting records by primary key | ||
* @param {object} Model The object model | ||
* @param {string} id The primary key | ||
* @returns {object} Returns record query | ||
*/ | ||
export const findById = async (Model, id) => { | ||
const record = await Model.findByPk(id); | ||
return record; | ||
}; | ||
|
||
/** | ||
* @name findAndCount | ||
* @description This is function for counting records via query | ||
* @param {object} Model The object model | ||
* @param {object|null|void} param The certain conditionals for the query to run | ||
* @returns {object} Returns record query | ||
*/ | ||
export const findAndCount = async (Model, param = null) => { | ||
const record = await Model.findAndCountAll(param); | ||
return record; | ||
}; | ||
|
||
export default findById; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters