@agentbadge/database 0.5.2 → 0.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -37,15 +37,17 @@ export class SpendApprovalRepository {
|
|
|
37
37
|
return this.db.orm.public.SpendApproval.where({ id }).first();
|
|
38
38
|
}
|
|
39
39
|
async listByWallet(wallet, state) {
|
|
40
|
-
let q = this.db.orm.public.SpendApproval.orderBy((a) => a.
|
|
40
|
+
let q = this.db.orm.public.SpendApproval.orderBy((a) => a.createdAt.desc()).where({ wallet: wallet.toLowerCase() });
|
|
41
41
|
if (state !== undefined)
|
|
42
42
|
q = q.where({ state });
|
|
43
|
-
|
|
43
|
+
const rows = await q.all();
|
|
44
|
+
return rows.sort((x, y) => Number(y.createdAtMs) - Number(x.createdAtMs));
|
|
44
45
|
}
|
|
45
46
|
async listAll(limit = 1_000) {
|
|
46
|
-
|
|
47
|
+
const rows = await this.db.orm.public.SpendApproval.orderBy((a) => a.createdAt.desc())
|
|
47
48
|
.limit(limit)
|
|
48
49
|
.all();
|
|
50
|
+
return rows.sort((x, y) => Number(y.createdAtMs) - Number(x.createdAtMs));
|
|
49
51
|
}
|
|
50
52
|
async decide(id, to, actor, decidedAtMs, expiresAtMs, payload) {
|
|
51
53
|
const row = await this.db.orm.public.SpendApproval.where({
|