@trafficgroup/knex-rel 0.0.3 → 0.0.4
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.
package/dist/d.types.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export interface IBaseDAO<T> {
|
|
|
11
11
|
create(item: T): Promise<T>;
|
|
12
12
|
getById(id: number): Promise<T | null>;
|
|
13
13
|
getByUuid(uuid: string): Promise<T | null>;
|
|
14
|
-
getAll(): Promise<IDataPaginator<T>>;
|
|
14
|
+
getAll(page: number, limit: number, entityId?: any | null): Promise<IDataPaginator<T>>;
|
|
15
15
|
update(id: number, item: T): Promise<T | null>;
|
|
16
16
|
delete(id: number): Promise<boolean>;
|
|
17
17
|
}
|
|
@@ -7,5 +7,5 @@ export declare class UserDAO implements IBaseDAO<IUser> {
|
|
|
7
7
|
getByUuid(uuid: string): Promise<IUser | null>;
|
|
8
8
|
update(id: number, item: Partial<IUser>): Promise<IUser | null>;
|
|
9
9
|
delete(id: number): Promise<boolean>;
|
|
10
|
-
getAll(): Promise<IDataPaginator<IUser>>;
|
|
10
|
+
getAll(page: number, limit: number): Promise<IDataPaginator<IUser>>;
|
|
11
11
|
}
|
|
@@ -48,10 +48,8 @@ class UserDAO {
|
|
|
48
48
|
return result > 0;
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
|
-
getAll() {
|
|
51
|
+
getAll(page, limit) {
|
|
52
52
|
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
-
const page = 1; // Default to first page
|
|
54
|
-
const limit = 10; // Default limit
|
|
55
53
|
const offset = (page - 1) * limit;
|
|
56
54
|
const [countResult] = yield this._knex("user").count("* as count");
|
|
57
55
|
const totalCount = +countResult.count;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.dao.js","sourceRoot":"","sources":["../../../src/dao/user/user.dao.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAGA,0EAA+C;AAE/C,MAAa,OAAO;IAApB;Q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AI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC;YAC5D,OAAO,MAAM,GAAG,CAAC,CAAC;QACtB,CAAC;KAAA;IAEK,MAAM,CAAC,IAAY,EAAE,KAAa;;YACpC,MAAM,MAAM,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC;YAElC,MAAM,CAAC,WAAW,CAAC,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;YACnE,MAAM,UAAU,GAAG,CAAC,WAAW,CAAC,KAAK,CAAC;YACtC,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YAEnE,OAAO;gBACH,OAAO,EAAE,IAAI;gBACb,IAAI,EAAE,KAAK;gBACX,IAAI;gBACJ,KAAK;gBACL,KAAK,EAAE,KAAK,CAAC,MAAM;gBACnB,UAAU;gBACV,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;aAC5C,CAAC;QACN,CAAC;KAAA;CACJ;AA7CD,0BA6CC"}
|
package/package.json
CHANGED
package/src/d.types.ts
CHANGED
|
@@ -6,13 +6,13 @@ export interface IDataPaginator<T> {
|
|
|
6
6
|
count: number;
|
|
7
7
|
totalCount: number;
|
|
8
8
|
totalPages: number;
|
|
9
|
-
}
|
|
9
|
+
}
|
|
10
10
|
|
|
11
11
|
export interface IBaseDAO<T> {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
create(item: T): Promise<T>;
|
|
13
|
+
getById(id: number): Promise<T | null>;
|
|
14
|
+
getByUuid(uuid: string): Promise<T | null>;
|
|
15
|
+
getAll(page: number, limit: number, entityId?: any | null): Promise<IDataPaginator<T>>;
|
|
16
|
+
update(id: number, item: T): Promise<T | null>;
|
|
17
|
+
delete(id: number): Promise<boolean>;
|
|
18
18
|
}
|
package/src/dao/user/user.dao.ts
CHANGED
|
@@ -31,9 +31,7 @@ export class UserDAO implements IBaseDAO<IUser> {
|
|
|
31
31
|
return result > 0;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
async getAll(): Promise<IDataPaginator<IUser>> {
|
|
35
|
-
const page = 1; // Default to first page
|
|
36
|
-
const limit = 10; // Default limit
|
|
34
|
+
async getAll(page: number, limit: number): Promise<IDataPaginator<IUser>> {
|
|
37
35
|
const offset = (page - 1) * limit;
|
|
38
36
|
|
|
39
37
|
const [countResult] = await this._knex("user").count("* as count");
|