ztechno_core 0.0.22 → 0.0.23

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.
@@ -15,6 +15,7 @@ export declare class ZUserService {
15
15
  private salt;
16
16
  constructor({ sqlService, tableName }: { sqlService: ZSqlService; tableName?: string });
17
17
  private checkTableExists;
18
+ checkTableHasAdmin(): Promise<boolean>;
18
19
  private createTable;
19
20
  ensureTableExists(): Promise<void>;
20
21
  register({ name, pass, role, admin }: ZRequiredUserColumns): Promise<void>;
@@ -16,6 +16,12 @@ class ZUserService {
16
16
  `);
17
17
  return res.length > 0;
18
18
  }
19
+ async checkTableHasAdmin() {
20
+ const res = await this.sqlService.query(`
21
+ SELECT id FROM \`${this.tableName}\` WHERE admin=1
22
+ `);
23
+ return res.length > 0;
24
+ }
19
25
  async createTable() {
20
26
  await this.sqlService.query(`
21
27
  CREATE TABLE \`${this.tableName}\` (
@@ -53,7 +59,7 @@ class ZUserService {
53
59
  const res = await this.sqlService.query(
54
60
  `
55
61
  SELECT id, name, role, admin, updated_at, created_at
56
- FROM ${this.tableName}
62
+ FROM \`${this.tableName}\`
57
63
  WHERE name=? AND pass=?
58
64
  `,
59
65
  [name, this.hashPass({ name, pass })],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ztechno_core",
3
- "version": "0.0.22",
3
+ "version": "0.0.23",
4
4
  "description": "Core files for ztechno framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",