This commit is contained in:
rgrgogu
2026-05-14 12:59:42 +08:00
parent 06c4286c4a
commit c3663572ae
12 changed files with 570 additions and 536 deletions
+3 -2
View File
@@ -81,7 +81,8 @@ async function paginate(model, req, {
jsonbColumn = null,
findOptions = {},
auditOptions = null, // ← { mdl_Users, parentAlias },
computedAttributes = []
computedAttributes = [],
context = "list",
} = {}) {
const page = Math.max(PAGE_START, parseInt(req.query.page, 10) || PAGE_START);
const limit = Math.min(parseInt(req.query.limit, 10) || PAGE_SIZE, MAX_LIMIT);
@@ -94,7 +95,7 @@ async function paginate(model, req, {
const jsonbExclude = excludeAttributes.filter((f) => f.includes('.'));
const jsonbAttr = jsonbColumn ? excludeJsonbPaths(jsonbColumn, jsonbExclude) : null;
const attributes = modelToAttributes(model, { exclude: excludeAttributes, jsonbSchemas });
const attributes = modelToAttributes(model, { exclude: excludeAttributes, jsonbSchemas, context });
const ALLOWED_FIELDS = attributes.map((a) => a.field);
const { where, order } = buildQuery(filters, sort, ALLOWED_FIELDS);