@syntropix/database 0.0.2 → 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/.env +1 -1
- package/.vscode/settings.json +1 -8
- package/dist/core/dataClient.d.ts +1 -1
- package/dist/core/dataClient.js +2 -6
- package/dist/core/tableClient.d.ts +3 -2
- package/dist/core/tableClient.js +2 -1
- package/dist/types/basemodel.d.ts +3 -2
- package/dist/types/dto/base.d.ts +4 -0
- package/dist/types/dto/base.js +1 -0
- package/dist/types/dto/table.d.ts +22 -0
- package/dist/types/dto/table.js +1 -0
- package/dist/types/filter.d.ts +8 -0
- package/dist/types/filter.js +24 -0
- package/dist/types/requests.d.ts +2 -41
- package/eslint.config.mjs +23 -23
- package/examples/tsconfig.json +13 -0
- package/examples/usage.ts +73 -52
- package/jest.config.ts +9 -10
- package/package.json +4 -4
- package/src/core/dataClient.ts +1 -6
- package/src/core/tableClient.ts +3 -2
- package/src/types/basemodel.ts +3 -2
- package/src/types/common.ts +83 -83
- package/src/types/dto/base.ts +4 -0
- package/src/types/dto/table.ts +21 -0
- package/src/types/filter.ts +28 -1
- package/src/types/requests.ts +2 -52
- package/tests/basic.test.ts +52 -34
- package/tests/tsconfig.json +8 -0
- package/tsconfig.json +18 -21
- package/examples/advanced-usage.d.ts +0 -42
- package/examples/advanced-usage.d.ts.map +0 -1
- package/examples/advanced-usage.js +0 -257
- package/examples/advanced-usage.js.map +0 -1
- package/examples/usage.d.ts +0 -11
- package/examples/usage.d.ts.map +0 -1
- package/examples/usage.js +0 -91
- package/examples/usage.js.map +0 -1
- package/tsconfig.base.json +0 -17
- package/tsconfig.test.json +0 -13
|
@@ -1,257 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.CompanyApiKey = exports.CompanyMember = exports.CompanyGroupMember = exports.CompanyGroup = void 0;
|
|
13
|
-
require("dotenv/config");
|
|
14
|
-
const config_1 = require("../src/core/config");
|
|
15
|
-
const syntropix_1 = require("../src/core/syntropix");
|
|
16
|
-
const basemodel_1 = require("../src/types/basemodel");
|
|
17
|
-
const filter_1 = require("../src/types/filter");
|
|
18
|
-
class CompanyGroup extends basemodel_1.BaseModel {
|
|
19
|
-
}
|
|
20
|
-
exports.CompanyGroup = CompanyGroup;
|
|
21
|
-
CompanyGroup.tableName = 'syntropix_company_groups';
|
|
22
|
-
CompanyGroup.description = 'Company groups';
|
|
23
|
-
__decorate([
|
|
24
|
-
(0, basemodel_1.Column)({
|
|
25
|
-
type: 'Integer',
|
|
26
|
-
primary: true,
|
|
27
|
-
auto_increment: true,
|
|
28
|
-
description: 'Group ID',
|
|
29
|
-
}),
|
|
30
|
-
__metadata("design:type", Number)
|
|
31
|
-
], CompanyGroup.prototype, "id", void 0);
|
|
32
|
-
__decorate([
|
|
33
|
-
(0, basemodel_1.Column)({ type: { String: 256 }, description: 'Group Name' }),
|
|
34
|
-
__metadata("design:type", String)
|
|
35
|
-
], CompanyGroup.prototype, "name", void 0);
|
|
36
|
-
__decorate([
|
|
37
|
-
(0, basemodel_1.Column)({ type: 'Text', description: 'Group Description' }),
|
|
38
|
-
__metadata("design:type", String)
|
|
39
|
-
], CompanyGroup.prototype, "description", void 0);
|
|
40
|
-
class CompanyGroupMember extends basemodel_1.BaseModel {
|
|
41
|
-
}
|
|
42
|
-
exports.CompanyGroupMember = CompanyGroupMember;
|
|
43
|
-
CompanyGroupMember.tableName = 'syntropix_company_group_members';
|
|
44
|
-
CompanyGroupMember.description = 'Company group members';
|
|
45
|
-
__decorate([
|
|
46
|
-
(0, basemodel_1.Column)({
|
|
47
|
-
type: 'Integer',
|
|
48
|
-
primary: true,
|
|
49
|
-
auto_increment: true,
|
|
50
|
-
description: 'Member ID',
|
|
51
|
-
}),
|
|
52
|
-
__metadata("design:type", Number)
|
|
53
|
-
], CompanyGroupMember.prototype, "id", void 0);
|
|
54
|
-
__decorate([
|
|
55
|
-
(0, basemodel_1.ForeignKey)('syntropix_company_groups', 'id', { description: 'Group ID' }),
|
|
56
|
-
__metadata("design:type", Number)
|
|
57
|
-
], CompanyGroupMember.prototype, "groupId", void 0);
|
|
58
|
-
__decorate([
|
|
59
|
-
(0, basemodel_1.ForeignKey)('syntropix_company_members', 'id', { description: 'Member ID' }),
|
|
60
|
-
__metadata("design:type", Number)
|
|
61
|
-
], CompanyGroupMember.prototype, "memberId", void 0);
|
|
62
|
-
class CompanyMember extends basemodel_1.BaseModel {
|
|
63
|
-
}
|
|
64
|
-
exports.CompanyMember = CompanyMember;
|
|
65
|
-
CompanyMember.tableName = 'syntropix_company_members';
|
|
66
|
-
CompanyMember.description = 'Company members';
|
|
67
|
-
__decorate([
|
|
68
|
-
(0, basemodel_1.Column)({
|
|
69
|
-
type: 'Integer',
|
|
70
|
-
primary: true,
|
|
71
|
-
auto_increment: true,
|
|
72
|
-
description: 'Member ID',
|
|
73
|
-
}),
|
|
74
|
-
__metadata("design:type", Number)
|
|
75
|
-
], CompanyMember.prototype, "id", void 0);
|
|
76
|
-
__decorate([
|
|
77
|
-
(0, basemodel_1.Column)({
|
|
78
|
-
type: { String: 256 },
|
|
79
|
-
description: 'User id in mongodb',
|
|
80
|
-
nullable: false,
|
|
81
|
-
name: 'user_id',
|
|
82
|
-
}),
|
|
83
|
-
__metadata("design:type", String)
|
|
84
|
-
], CompanyMember.prototype, "userId", void 0);
|
|
85
|
-
__decorate([
|
|
86
|
-
(0, basemodel_1.Column)({
|
|
87
|
-
type: { String: 256 },
|
|
88
|
-
description: 'First Name',
|
|
89
|
-
nullable: false,
|
|
90
|
-
name: 'first_name',
|
|
91
|
-
}),
|
|
92
|
-
__metadata("design:type", String)
|
|
93
|
-
], CompanyMember.prototype, "firstName", void 0);
|
|
94
|
-
__decorate([
|
|
95
|
-
(0, basemodel_1.Column)({
|
|
96
|
-
type: { String: 256 },
|
|
97
|
-
description: 'Last Name',
|
|
98
|
-
nullable: false,
|
|
99
|
-
name: 'last_name',
|
|
100
|
-
}),
|
|
101
|
-
__metadata("design:type", String)
|
|
102
|
-
], CompanyMember.prototype, "lastName", void 0);
|
|
103
|
-
__decorate([
|
|
104
|
-
(0, basemodel_1.Column)({
|
|
105
|
-
type: { String: 256 },
|
|
106
|
-
description: 'Middle Name',
|
|
107
|
-
nullable: true,
|
|
108
|
-
name: 'middle_name',
|
|
109
|
-
}),
|
|
110
|
-
__metadata("design:type", Object)
|
|
111
|
-
], CompanyMember.prototype, "middleName", void 0);
|
|
112
|
-
__decorate([
|
|
113
|
-
(0, basemodel_1.Column)({
|
|
114
|
-
type: { String: 256 },
|
|
115
|
-
description: 'Email',
|
|
116
|
-
nullable: false,
|
|
117
|
-
name: 'email',
|
|
118
|
-
}),
|
|
119
|
-
__metadata("design:type", String)
|
|
120
|
-
], CompanyMember.prototype, "email", void 0);
|
|
121
|
-
__decorate([
|
|
122
|
-
(0, basemodel_1.Column)({
|
|
123
|
-
type: { String: 256 },
|
|
124
|
-
description: 'Avatar',
|
|
125
|
-
nullable: true,
|
|
126
|
-
name: 'avatar',
|
|
127
|
-
}),
|
|
128
|
-
__metadata("design:type", Object)
|
|
129
|
-
], CompanyMember.prototype, "avatar", void 0);
|
|
130
|
-
__decorate([
|
|
131
|
-
(0, basemodel_1.Column)({ type: 'Text', description: 'Bio', nullable: true, name: 'bio' }),
|
|
132
|
-
__metadata("design:type", String)
|
|
133
|
-
], CompanyMember.prototype, "bio", void 0);
|
|
134
|
-
__decorate([
|
|
135
|
-
(0, basemodel_1.Column)({
|
|
136
|
-
type: { String: 32 },
|
|
137
|
-
description: 'Role',
|
|
138
|
-
nullable: false,
|
|
139
|
-
name: 'role',
|
|
140
|
-
}),
|
|
141
|
-
__metadata("design:type", String)
|
|
142
|
-
], CompanyMember.prototype, "role", void 0);
|
|
143
|
-
__decorate([
|
|
144
|
-
(0, basemodel_1.Column)({
|
|
145
|
-
type: { String: 256 },
|
|
146
|
-
description: 'Personal Key',
|
|
147
|
-
nullable: false,
|
|
148
|
-
name: 'personal_key',
|
|
149
|
-
}),
|
|
150
|
-
__metadata("design:type", String)
|
|
151
|
-
], CompanyMember.prototype, "personalKey", void 0);
|
|
152
|
-
class CompanyApiKey extends basemodel_1.BaseModel {
|
|
153
|
-
}
|
|
154
|
-
exports.CompanyApiKey = CompanyApiKey;
|
|
155
|
-
CompanyApiKey.tableName = 'syntropix_company_api_keys';
|
|
156
|
-
CompanyApiKey.description = 'Company API keys';
|
|
157
|
-
__decorate([
|
|
158
|
-
(0, basemodel_1.Column)({
|
|
159
|
-
type: 'Integer',
|
|
160
|
-
primary: true,
|
|
161
|
-
auto_increment: true,
|
|
162
|
-
description: 'API Key ID',
|
|
163
|
-
}),
|
|
164
|
-
__metadata("design:type", Number)
|
|
165
|
-
], CompanyApiKey.prototype, "id", void 0);
|
|
166
|
-
__decorate([
|
|
167
|
-
(0, basemodel_1.Column)({
|
|
168
|
-
type: { String: 256 },
|
|
169
|
-
description: 'Name',
|
|
170
|
-
nullable: false,
|
|
171
|
-
name: 'name',
|
|
172
|
-
}),
|
|
173
|
-
__metadata("design:type", String)
|
|
174
|
-
], CompanyApiKey.prototype, "name", void 0);
|
|
175
|
-
__decorate([
|
|
176
|
-
(0, basemodel_1.Column)({
|
|
177
|
-
type: 'Text',
|
|
178
|
-
description: 'Description',
|
|
179
|
-
nullable: true,
|
|
180
|
-
name: 'description',
|
|
181
|
-
}),
|
|
182
|
-
__metadata("design:type", Object)
|
|
183
|
-
], CompanyApiKey.prototype, "description", void 0);
|
|
184
|
-
__decorate([
|
|
185
|
-
(0, basemodel_1.Column)({
|
|
186
|
-
type: { String: 256 },
|
|
187
|
-
description: 'Key',
|
|
188
|
-
nullable: false,
|
|
189
|
-
name: 'key',
|
|
190
|
-
}),
|
|
191
|
-
__metadata("design:type", String)
|
|
192
|
-
], CompanyApiKey.prototype, "key", void 0);
|
|
193
|
-
__decorate([
|
|
194
|
-
(0, basemodel_1.Column)({
|
|
195
|
-
type: 'DateTime',
|
|
196
|
-
description: 'Created At',
|
|
197
|
-
nullable: false,
|
|
198
|
-
name: 'created_at',
|
|
199
|
-
}),
|
|
200
|
-
__metadata("design:type", Object)
|
|
201
|
-
], CompanyApiKey.prototype, "createdAt", void 0);
|
|
202
|
-
__decorate([
|
|
203
|
-
(0, basemodel_1.Column)({
|
|
204
|
-
type: 'Boolean',
|
|
205
|
-
description: 'Is Personal',
|
|
206
|
-
nullable: false,
|
|
207
|
-
name: 'is_personal',
|
|
208
|
-
}),
|
|
209
|
-
__metadata("design:type", Boolean)
|
|
210
|
-
], CompanyApiKey.prototype, "isPersonal", void 0);
|
|
211
|
-
__decorate([
|
|
212
|
-
(0, basemodel_1.ForeignKey)('syntropix_company_members', 'id', { description: 'Created By', name: 'created_by' }),
|
|
213
|
-
__metadata("design:type", Number)
|
|
214
|
-
], CompanyApiKey.prototype, "createdBy", void 0);
|
|
215
|
-
// Example usage
|
|
216
|
-
async function examples() {
|
|
217
|
-
const _client = new syntropix_1.SyntropixClient(new config_1.ClientConfig());
|
|
218
|
-
console.log(CompanyApiKey.getDescription());
|
|
219
|
-
const member = await CompanyMember.filter({
|
|
220
|
-
filter: (0, filter_1.OR)((0, filter_1.AND)((0, filter_1.GTE)('id', 0))),
|
|
221
|
-
});
|
|
222
|
-
console.log(member);
|
|
223
|
-
// await CompanyMember.dropTable(_client);
|
|
224
|
-
// await CompanyApiKey.dropTable(_client);
|
|
225
|
-
// await CompanyMember.createTable(_client);
|
|
226
|
-
// await CompanyGroup.createTable(_client);
|
|
227
|
-
// await CompanyApiKey.createTable(_client);
|
|
228
|
-
// await CompanyGroupMember.createTable(_client);
|
|
229
|
-
// await CompanyMember.create(
|
|
230
|
-
// {
|
|
231
|
-
// userId: "1234567890",
|
|
232
|
-
// firstName: "John",
|
|
233
|
-
// lastName: "Doe",
|
|
234
|
-
// middleName: "Doe",
|
|
235
|
-
// email: "john.doe@example.com",
|
|
236
|
-
// avatar: "https://example.com/avatar.png",
|
|
237
|
-
// bio: "",
|
|
238
|
-
// role: "admin",
|
|
239
|
-
// personalKey: "1234567890",
|
|
240
|
-
// },
|
|
241
|
-
// _client
|
|
242
|
-
// );
|
|
243
|
-
// await CompanyApiKey.create(
|
|
244
|
-
// {
|
|
245
|
-
// name: "Admin API Key for John Doe",
|
|
246
|
-
// description: "Admin API Key for John Doe",
|
|
247
|
-
// key: "1234567890",
|
|
248
|
-
// createdAt: new Date(),
|
|
249
|
-
// createdBy: 1,
|
|
250
|
-
// isPersonal: true,
|
|
251
|
-
// },
|
|
252
|
-
// _client
|
|
253
|
-
// );
|
|
254
|
-
}
|
|
255
|
-
// Run examples
|
|
256
|
-
examples().catch(console.error);
|
|
257
|
-
//# sourceMappingURL=advanced-usage.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"advanced-usage.js","sourceRoot":"","sources":["advanced-usage.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yBAAuB;AACvB,+CAAkD;AAClD,qDAAwD;AACxD,sDAAuE;AACvE,gDAAmD;AAEnD,MAAa,YAAa,SAAQ,qBAAS;;AAA3C,oCAiBC;AAhBQ,sBAAS,GAAG,0BAA0B,CAAC;AACvC,wBAAW,GAAG,gBAA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BAAU,EAAC,2BAA2B,EAAE,IAAI,EAAE,EAAE,WAAW,EAAE,YAAY,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;;gDAC9E;AAGrB,gBAAgB;AAChB,KAAK,UAAU,QAAQ;IACrB,MAAM,OAAO,GAAG,IAAI,2BAAe,CAAC,IAAI,qBAAY,EAAE,CAAC,CAAC;IACxD,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,cAAc,EAAE,CAAC,CAAC;IAC5C,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,MAAM,CAAC;QACxC,MAAM,EAAE,IAAA,WAAE,EAAC,IAAA,YAAG,EAAC,IAAA,YAAG,EAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;KAC9B,CAAC,CAAC;IACH,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACpB,0CAA0C;IAC1C,0CAA0C;IAC1C,4CAA4C;IAC5C,2CAA2C;IAC3C,4CAA4C;IAC5C,iDAAiD;IAEjD,8BAA8B;IAC9B,MAAM;IACN,4BAA4B;IAC5B,yBAAyB;IACzB,uBAAuB;IACvB,yBAAyB;IACzB,qCAAqC;IACrC,gDAAgD;IAChD,eAAe;IACf,qBAAqB;IACrB,iCAAiC;IACjC,OAAO;IACP,YAAY;IACZ,KAAK;IAEL,8BAA8B;IAC9B,MAAM;IACN,0CAA0C;IAC1C,iDAAiD;IACjD,yBAAyB;IACzB,6BAA6B;IAC7B,oBAAoB;IACpB,wBAAwB;IACxB,OAAO;IACP,YAAY;IACZ,KAAK;AACP,CAAC;AAED,eAAe;AACf,QAAQ,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC"}
|
package/examples/usage.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import 'dotenv/config';
|
|
2
|
-
import { BaseModel } from '../src/types/basemodel';
|
|
3
|
-
export declare class User extends BaseModel {
|
|
4
|
-
static tableName: string;
|
|
5
|
-
id: number;
|
|
6
|
-
email: string;
|
|
7
|
-
fullName: string;
|
|
8
|
-
profile?: any;
|
|
9
|
-
isActive: boolean;
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=usage.d.ts.map
|
package/examples/usage.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"usage.d.ts","sourceRoot":"","sources":["usage.ts"],"names":[],"mappings":"AACA,OAAO,eAAe,CAAC;AACvB,OAAO,EAAE,SAAS,EAAU,MAAM,wBAAwB,CAAC;AAI3D,qBAAa,IAAK,SAAQ,SAAS;IACjC,MAAM,CAAC,SAAS,SAAW;IAEuC,EAAE,EAAG,MAAM,CAAC;IACpE,KAAK,EAAG,MAAM,CAAC;IACM,QAAQ,EAAG,MAAM,CAAC;IACP,OAAO,CAAC,EAAE,GAAG,CAAC;IACR,QAAQ,EAAG,OAAO,CAAC;CACpE"}
|
package/examples/usage.js
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.User = void 0;
|
|
13
|
-
// Example usage of the BaseModel ORM
|
|
14
|
-
require("dotenv/config");
|
|
15
|
-
const basemodel_1 = require("../src/types/basemodel");
|
|
16
|
-
const filter_1 = require("../src/types/filter");
|
|
17
|
-
// User model extending Audited
|
|
18
|
-
class User extends basemodel_1.BaseModel {
|
|
19
|
-
}
|
|
20
|
-
exports.User = User;
|
|
21
|
-
User.tableName = 'users';
|
|
22
|
-
__decorate([
|
|
23
|
-
(0, basemodel_1.Column)({ type: 'Integer', primary: true, auto_increment: true }),
|
|
24
|
-
__metadata("design:type", Number)
|
|
25
|
-
], User.prototype, "id", void 0);
|
|
26
|
-
__decorate([
|
|
27
|
-
(0, basemodel_1.Column)(),
|
|
28
|
-
__metadata("design:type", String)
|
|
29
|
-
], User.prototype, "email", void 0);
|
|
30
|
-
__decorate([
|
|
31
|
-
(0, basemodel_1.Column)({ name: 'full_name' }),
|
|
32
|
-
__metadata("design:type", String)
|
|
33
|
-
], User.prototype, "fullName", void 0);
|
|
34
|
-
__decorate([
|
|
35
|
-
(0, basemodel_1.Column)({ type: 'Json', nullable: true }),
|
|
36
|
-
__metadata("design:type", Object)
|
|
37
|
-
], User.prototype, "profile", void 0);
|
|
38
|
-
__decorate([
|
|
39
|
-
(0, basemodel_1.Column)({ type: 'Boolean', name: 'is_active' }),
|
|
40
|
-
__metadata("design:type", Boolean)
|
|
41
|
-
], User.prototype, "isActive", void 0);
|
|
42
|
-
// Example usage
|
|
43
|
-
async function examples() {
|
|
44
|
-
// Create table
|
|
45
|
-
// await User.createTable();
|
|
46
|
-
// Create a new user
|
|
47
|
-
const newUser = await User.create({
|
|
48
|
-
id: 1,
|
|
49
|
-
email: 'user@example.com',
|
|
50
|
-
fullName: 'John Doe',
|
|
51
|
-
isActive: true,
|
|
52
|
-
});
|
|
53
|
-
// Get a user
|
|
54
|
-
const user = await User.get((0, filter_1.OR)((0, filter_1.AND)((0, filter_1.EQ)('email', 'user@example.com'))));
|
|
55
|
-
console.log(user);
|
|
56
|
-
// Update user
|
|
57
|
-
user.fullName = 'Jane Doe1';
|
|
58
|
-
await user.save();
|
|
59
|
-
// // Filter users
|
|
60
|
-
const activeUsers = await User.filter({
|
|
61
|
-
filter: (0, filter_1.OR)((0, filter_1.AND)((0, filter_1.EQ)('is_active', true))),
|
|
62
|
-
limit: 10,
|
|
63
|
-
});
|
|
64
|
-
// // Count users
|
|
65
|
-
const userCount = await User.count({
|
|
66
|
-
filter: (0, filter_1.OR)((0, filter_1.AND)((0, filter_1.EQ)('is_active', true))),
|
|
67
|
-
});
|
|
68
|
-
console.log(activeUsers);
|
|
69
|
-
console.log(userCount);
|
|
70
|
-
// // Delete user
|
|
71
|
-
await user.remove();
|
|
72
|
-
// // Bulk create
|
|
73
|
-
await User.bulkCreate([
|
|
74
|
-
{
|
|
75
|
-
id: 2,
|
|
76
|
-
email: 'user2@example.com',
|
|
77
|
-
fullName: 'User 2',
|
|
78
|
-
isActive: true,
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
id: 3,
|
|
82
|
-
email: 'user3@example.com',
|
|
83
|
-
fullName: 'User 3',
|
|
84
|
-
isActive: false,
|
|
85
|
-
},
|
|
86
|
-
]);
|
|
87
|
-
// console.log('All operations completed successfully!');
|
|
88
|
-
}
|
|
89
|
-
// Run examples
|
|
90
|
-
examples().catch(console.error);
|
|
91
|
-
//# sourceMappingURL=usage.js.map
|
package/examples/usage.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"usage.js","sourceRoot":"","sources":["usage.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAqC;AACrC,yBAAuB;AACvB,sDAA2D;AAC3D,gDAAkD;AAElD,+BAA+B;AAC/B,MAAa,IAAK,SAAQ,qBAAS;;AAAnC,oBAQC;AAPQ,cAAS,GAAG,OAAO,CAAC;AAEuC;IAAjE,IAAA,kBAAM,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC;;gCAAa;AACpE;IAAT,IAAA,kBAAM,GAAE;;mCAAgB;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AC,CAAC;KACvC,CAAC,CAAC;IACH,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IACzB,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IACvB,iBAAiB;IACjB,MAAM,IAAI,CAAC,MAAM,EAAE,CAAC;IAEpB,iBAAiB;IACjB,MAAM,IAAI,CAAC,UAAU,CAAC;QACpB;YACE,EAAE,EAAE,CAAC;YACL,KAAK,EAAE,mBAAmB;YAC1B,QAAQ,EAAE,QAAQ;YAClB,QAAQ,EAAE,IAAI;SACf;QACD;YACE,EAAE,EAAE,CAAC;YACL,KAAK,EAAE,mBAAmB;YAC1B,QAAQ,EAAE,QAAQ;YAClB,QAAQ,EAAE,KAAK;SAChB;KACF,CAAC,CAAC;IAEH,yDAAyD;AAC3D,CAAC;AAED,eAAe;AACf,QAAQ,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC"}
|
package/tsconfig.base.json
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2022",
|
|
4
|
-
"module": "ESNext",
|
|
5
|
-
"moduleResolution": "Bundler",
|
|
6
|
-
"esModuleInterop": true,
|
|
7
|
-
"strict": true,
|
|
8
|
-
"experimentalDecorators": true,
|
|
9
|
-
"emitDecoratorMetadata": true,
|
|
10
|
-
"baseUrl": ".",
|
|
11
|
-
"paths": {
|
|
12
|
-
"@/*": [
|
|
13
|
-
"src/*"
|
|
14
|
-
]
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
}
|
package/tsconfig.test.json
DELETED