fix: Optimize query methods

This commit is contained in:
Maksim Eltyshev
2025-11-27 19:09:10 +01:00
parent 26b3cffdab
commit 0023c63be8
8 changed files with 143 additions and 207 deletions

View File

@@ -3,9 +3,10 @@
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
*/
const { makeWhereQueryBuilder } = require('../helpers');
const { makeRowToModelTransformer, makeWhereQueryBuilder } = require('../helpers');
const buildWhereQuery = makeWhereQueryBuilder(List);
const transformRowToModel = makeRowToModelTransformer(List);
const defaultFind = (criteria, { sort = 'id' } = {}) => List.find(criteria).sort(sort);
@@ -67,10 +68,7 @@ const updateOne = async (criteria, values) => {
return { list: null };
}
const prev = {
boardId: queryResult.rows[0].board_id,
type: queryResult.rows[0].type,
};
const prev = transformRowToModel(queryResult.rows[0]);
const list = await List.updateOne(criteria)
.set({ ...values })