Skip to content
This repository has been archived by the owner on Sep 12, 2023. It is now read-only.

Commit

Permalink
intrn(manager): integrate the count in document
Browse files Browse the repository at this point in the history
  • Loading branch information
KennethTrecy committed Nov 23, 2022
1 parent 5414e8d commit 8e3b6e3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions database/managers/user.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ describe("Database Manager: User read operations", () => {
expect(users).toHaveProperty("data")
expect(users.data).toHaveLength(1)
expect(users).toHaveProperty("data.0.attributes.email", model.email)
expect(users).toHaveProperty("meta.count", 1)
})

it("cannot get user that can reset password", async() => {
Expand All @@ -184,6 +185,7 @@ describe("Database Manager: User read operations", () => {

expect(users).toHaveProperty("data")
expect(users.data).toHaveLength(0)
expect(users).toHaveProperty("meta.count", 0)
})
})

Expand Down
9 changes: 7 additions & 2 deletions database/managers/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ import type {
import Log from "$!/singletons/log"
import deserialize from "$/object/deserialize"
import runThroughPipeline from "$/helpers/run_through_pipeline"
import { RESET_PASSWORD } from "$/permissions/user_combinations"
import convertTimeToMinutes from "$/time/convert_time_to_minutes"

import { RESET_PASSWORD } from "$/permissions/user_combinations"
import { user as permissionGroup } from "$/permissions/permission_list"

import Role from "%/models/role"
Expand Down Expand Up @@ -310,7 +311,11 @@ export default class UserManager extends BaseManager<Model, RawUser, UserQueryPa
...this.transaction.transactionObject
})

return await this.serialize(rows)
const document = await this.serialize(rows) as Serializable

this.integrateCount(document, count)

return document
} catch (error) {
throw this.makeBaseError(error)
}
Expand Down

0 comments on commit 8e3b6e3

Please sign in to comment.