Handle users.demote event (#6315)
* fix: Handle users.demote event * fix: fetchAll * fix: fetch based on total
This commit is contained in:
@@ -152,12 +152,15 @@ router.post(
|
||||
sort = "updatedAt";
|
||||
}
|
||||
|
||||
const documents = await Document.defaultScopeWithUser(user.id).findAll({
|
||||
where,
|
||||
order: [[sort, direction]],
|
||||
offset: ctx.state.pagination.offset,
|
||||
limit: ctx.state.pagination.limit,
|
||||
});
|
||||
const [documents, total] = await Promise.all([
|
||||
Document.defaultScopeWithUser(user.id).findAll({
|
||||
where,
|
||||
order: [[sort, direction]],
|
||||
offset: ctx.state.pagination.offset,
|
||||
limit: ctx.state.pagination.limit,
|
||||
}),
|
||||
Document.count({ where }),
|
||||
]);
|
||||
|
||||
// index sort is special because it uses the order of the documents in the
|
||||
// collection.documentStructure rather than a database column
|
||||
@@ -172,7 +175,7 @@ router.post(
|
||||
);
|
||||
const policies = presentPolicies(user, documents);
|
||||
ctx.body = {
|
||||
pagination: ctx.state.pagination,
|
||||
pagination: { ...ctx.state.pagination, total },
|
||||
data,
|
||||
policies,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user