@axium/server 0.6.2 → 0.6.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.
@@ -56,6 +56,7 @@ export interface Stats {
56
56
  accounts: number;
57
57
  sessions: number;
58
58
  }
59
+ export declare function count(table: keyof Schema): Promise<number>;
59
60
  export declare function status(): Promise<Stats>;
60
61
  export declare function statusText(): Promise<string>;
61
62
  export interface OpOptions extends MaybeOutput {
package/dist/database.js CHANGED
@@ -70,12 +70,15 @@ export function connect() {
70
70
  });
71
71
  return database;
72
72
  }
73
- export async function status() {
73
+ export async function count(table) {
74
74
  const db = connect();
75
+ return (await db.selectFrom(table).select(db.fn.countAll().as('count')).executeTakeFirstOrThrow()).count;
76
+ }
77
+ export async function status() {
75
78
  return {
76
- users: (await db.selectFrom('User').select(db.fn.countAll().as('count')).executeTakeFirstOrThrow()).count,
77
- accounts: (await db.selectFrom('Account').select(db.fn.countAll().as('count')).executeTakeFirstOrThrow()).count,
78
- sessions: (await db.selectFrom('Session').select(db.fn.countAll().as('count')).executeTakeFirstOrThrow()).count,
79
+ users: await count('User'),
80
+ accounts: await count('Account'),
81
+ sessions: await count('Session'),
79
82
  };
80
83
  }
81
84
  export async function statusText() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axium/server",
3
- "version": "0.6.2",
3
+ "version": "0.6.3",
4
4
  "author": "James Prevett <axium@jamespre.dev> (https://jamespre.dev)",
5
5
  "funding": {
6
6
  "type": "individual",