mirror of
https://github.com/plankanban/planka.git
synced 2025-12-23 09:15:09 +03:00
fix: Optimize query methods
This commit is contained in:
@@ -172,16 +172,7 @@ const delete_ = (criteria) =>
|
||||
query += `END END, updated_at = $${queryValues.length} WHERE id IN (${inValues.join(', ')}) AND references_total IS NOT NULL RETURNING *`;
|
||||
|
||||
const queryResult = await sails.sendNativeQuery(query, queryValues).usingConnection(db);
|
||||
|
||||
uploadedFiles = queryResult.rows.map((row) => ({
|
||||
id: row.id,
|
||||
type: row.type,
|
||||
mimeType: row.mime_type,
|
||||
size: row.size,
|
||||
referencesTotal: row.references_total,
|
||||
createdAt: row.created_at,
|
||||
updatedAt: row.updated_at,
|
||||
}));
|
||||
uploadedFiles = queryResult.rows.map((row) => UploadedFile.qm.transformRowToModel(row));
|
||||
}
|
||||
|
||||
return { attachments, uploadedFiles };
|
||||
@@ -200,17 +191,7 @@ const deleteOne = (criteria) =>
|
||||
)
|
||||
.usingConnection(db);
|
||||
|
||||
const [row] = queryResult.rows;
|
||||
|
||||
uploadedFile = {
|
||||
id: row.id,
|
||||
type: row.type,
|
||||
mimeType: row.mime_type,
|
||||
size: row.size,
|
||||
referencesTotal: row.references_total,
|
||||
createdAt: row.created_at,
|
||||
updatedAt: row.updated_at,
|
||||
};
|
||||
uploadedFile = UploadedFile.qm.transformRowToModel(queryResult.rows[0]);
|
||||
}
|
||||
|
||||
return { attachment, uploadedFile };
|
||||
|
||||
Reference in New Issue
Block a user