@rws-framework/db 2.4.6 → 3.0.1

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.
Files changed (123) hide show
  1. package/.bin/add-v.sh +9 -9
  2. package/.bin/emerge.sh +10 -10
  3. package/.eslintrc.json +53 -53
  4. package/README.md +343 -405
  5. package/dist/decorators/IdType.d.ts +8 -0
  6. package/dist/decorators/IdType.js +10 -0
  7. package/dist/decorators/InverseRelation.d.ts +2 -2
  8. package/dist/decorators/InverseRelation.js +5 -1
  9. package/dist/decorators/InverseTimeSeries.d.ts +0 -0
  10. package/dist/decorators/InverseTimeSeries.js +0 -0
  11. package/dist/decorators/RWSCollection.d.ts +7 -0
  12. package/dist/decorators/RWSCollection.js +6 -0
  13. package/dist/decorators/Relation.d.ts +8 -6
  14. package/dist/decorators/Relation.js +8 -1
  15. package/dist/decorators/TrackType.d.ts +2 -14
  16. package/dist/decorators/TrackType.js +7 -0
  17. package/dist/decorators/TypeFunctions.d.ts +44 -0
  18. package/dist/decorators/TypeFunctions.js +174 -0
  19. package/dist/decorators/index.d.ts +4 -2
  20. package/dist/decorators/index.js +3 -1
  21. package/dist/helper/DbHelper.d.ts +76 -5
  22. package/dist/helper/DbHelper.js +93 -154
  23. package/dist/helper/FieldsHelper.d.ts +0 -0
  24. package/dist/helper/FieldsHelper.js +0 -0
  25. package/dist/helper/db/index.d.ts +9 -0
  26. package/dist/helper/db/index.js +18 -0
  27. package/dist/helper/db/relation-manager.d.ts +45 -0
  28. package/dist/helper/db/relation-manager.js +105 -0
  29. package/dist/helper/db/schema-generator.d.ts +37 -0
  30. package/dist/helper/db/schema-generator.js +255 -0
  31. package/dist/helper/db/type-converter.d.ts +22 -0
  32. package/dist/helper/db/type-converter.js +106 -0
  33. package/dist/helper/db/utils.d.ts +24 -0
  34. package/dist/helper/db/utils.js +99 -0
  35. package/dist/index.d.ts +3 -3
  36. package/dist/index.js +2 -1
  37. package/dist/models/TimeSeriesModel.d.ts +7 -7
  38. package/dist/models/TimeSeriesModel.js +33 -33
  39. package/dist/models/_model.d.ts +2 -2
  40. package/dist/models/_model.js +0 -0
  41. package/dist/models/core/RWSModel.d.ts +5 -2
  42. package/dist/models/core/RWSModel.js +8 -5
  43. package/dist/models/core/TimeSeriesModel.d.ts +0 -0
  44. package/dist/models/core/TimeSeriesModel.js +0 -0
  45. package/dist/models/index.d.ts +2 -2
  46. package/dist/models/index.js +0 -0
  47. package/dist/models/interfaces/IDbOpts.d.ts +17 -0
  48. package/dist/models/interfaces/IDbOpts.js +2 -0
  49. package/dist/models/interfaces/IIdOpts.d.ts +0 -0
  50. package/dist/models/interfaces/IIdOpts.js +1 -0
  51. package/dist/models/interfaces/IIdTypeOpts.d.ts +3 -0
  52. package/dist/models/interfaces/IIdTypeOpts.js +2 -0
  53. package/dist/models/interfaces/IModel.d.ts +0 -0
  54. package/dist/models/interfaces/IModel.js +0 -0
  55. package/dist/models/interfaces/IRWSModelServices.d.ts +0 -0
  56. package/dist/models/interfaces/IRWSModelServices.js +0 -0
  57. package/dist/models/interfaces/ITrackerOpts.d.ts +12 -0
  58. package/dist/models/interfaces/ITrackerOpts.js +2 -0
  59. package/dist/models/interfaces/OpModelType.d.ts +4 -1
  60. package/dist/models/interfaces/OpModelType.js +0 -0
  61. package/dist/models/types/RelationTypes.d.ts +0 -0
  62. package/dist/models/types/RelationTypes.js +0 -0
  63. package/dist/models/utils/ModelUtils.d.ts +0 -0
  64. package/dist/models/utils/ModelUtils.js +0 -0
  65. package/dist/models/utils/PaginationUtils.d.ts +0 -0
  66. package/dist/models/utils/PaginationUtils.js +0 -0
  67. package/dist/models/utils/RelationUtils.d.ts +1 -1
  68. package/dist/models/utils/RelationUtils.js +2 -2
  69. package/dist/models/utils/TimeSeriesUtils.d.ts +0 -0
  70. package/dist/models/utils/TimeSeriesUtils.js +0 -0
  71. package/dist/services/DBService.d.ts +0 -0
  72. package/dist/services/DBService.js +0 -0
  73. package/dist/types/DbConfigHandler.d.ts +1 -1
  74. package/dist/types/DbConfigHandler.js +0 -0
  75. package/dist/types/FindParams.d.ts +0 -0
  76. package/dist/types/FindParams.js +0 -0
  77. package/dist/types/IRWSModel.d.ts +1 -1
  78. package/dist/types/IRWSModel.js +0 -0
  79. package/dist/types/ITimeSeries.d.ts +0 -0
  80. package/dist/types/ITimeSeries.js +0 -0
  81. package/exec/console.js +110 -110
  82. package/exec/db.rws.webpack.config.js +168 -168
  83. package/exec/src/cli.ts +73 -75
  84. package/exec/tsconfig.json +32 -32
  85. package/exec/webpackFilters.js +17 -17
  86. package/package.json +36 -36
  87. package/src/decorators/IdType.ts +17 -0
  88. package/src/decorators/InverseRelation.ts +41 -37
  89. package/src/decorators/InverseTimeSeries.ts +21 -21
  90. package/src/decorators/RWSCollection.ts +45 -27
  91. package/src/decorators/Relation.ts +61 -48
  92. package/src/decorators/TrackType.ts +65 -69
  93. package/src/decorators/index.ts +16 -8
  94. package/src/empty.js +0 -0
  95. package/src/helper/DbHelper.ts +133 -223
  96. package/src/helper/FieldsHelper.ts +34 -34
  97. package/src/helper/db/index.ts +10 -0
  98. package/src/helper/db/relation-manager.ts +119 -0
  99. package/src/helper/db/schema-generator.ts +318 -0
  100. package/src/helper/db/type-converter.ts +119 -0
  101. package/src/helper/db/utils.ts +120 -0
  102. package/src/index.ts +47 -38
  103. package/src/models/_model.ts +29 -29
  104. package/src/models/core/RWSModel.ts +529 -520
  105. package/src/models/core/TimeSeriesModel.ts +19 -19
  106. package/src/models/index.ts +20 -20
  107. package/src/models/interfaces/IDbOpts.ts +17 -0
  108. package/src/models/interfaces/IIdTypeOpts.ts +4 -0
  109. package/src/models/interfaces/IModel.ts +12 -12
  110. package/src/models/interfaces/IRWSModelServices.ts +7 -7
  111. package/src/models/interfaces/ITrackerOpts.ts +13 -0
  112. package/src/models/interfaces/OpModelType.ts +52 -49
  113. package/src/models/types/RelationTypes.ts +25 -25
  114. package/src/models/utils/ModelUtils.ts +65 -65
  115. package/src/models/utils/PaginationUtils.ts +42 -42
  116. package/src/models/utils/RelationUtils.ts +76 -76
  117. package/src/models/utils/TimeSeriesUtils.ts +38 -38
  118. package/src/services/DBService.ts +277 -277
  119. package/src/types/DbConfigHandler.ts +17 -17
  120. package/src/types/FindParams.ts +13 -13
  121. package/src/types/IRWSModel.ts +2 -2
  122. package/src/types/ITimeSeries.ts +5 -5
  123. package/tsconfig.json +22 -22
@@ -1,277 +1,277 @@
1
- import { PrismaClient } from '@prisma/client';
2
- import { Collection, Db, MongoClient } from 'mongodb';
3
- import {ITimeSeries} from '../types/ITimeSeries';
4
- import { IModel } from '../models/interfaces/IModel';
5
- import chalk from 'chalk';
6
- import { IDbConfigHandler } from '../types/DbConfigHandler';
7
- import { IPaginationParams } from '../types/FindParams';
8
-
9
- interface IDBClientCreate {
10
- dbUrl?: string;
11
- dbName?: string;
12
- }
13
-
14
- class DBService {
15
- private client: PrismaClient;
16
- private opts: IDBClientCreate = null;
17
- private connected = false;
18
-
19
- constructor(private configService: IDbConfigHandler){}
20
-
21
- private connectToDB(opts: IDBClientCreate = null) {
22
- if(opts){
23
- this.opts = opts;
24
- }else{
25
- this.opts = {
26
- dbUrl: this.configService.get('db_url'),
27
- dbName: this.configService.get('db_name'),
28
- };
29
- }
30
-
31
- if(!this.opts.dbUrl){
32
- console.log(chalk.red('No database config set in @rws-framework/db'));
33
-
34
- return;
35
- }
36
-
37
- try{
38
- this.client = new PrismaClient({
39
- datasources: {
40
- db: {
41
- url: this.opts.dbUrl
42
- },
43
- },
44
- });
45
-
46
- this.connected = true;
47
- } catch (e: Error | any){
48
- console.error(e);
49
-
50
- throw new Error('PRISMA CONNECTION ERROR');
51
- }
52
- }
53
-
54
- reconnect(opts: IDBClientCreate = null)
55
- {
56
- this.connectToDB(opts);
57
- }
58
-
59
- static baseClientConstruct(dbUrl: string): MongoClient
60
- {
61
- const client = new MongoClient(dbUrl);
62
-
63
- return client;
64
- }
65
-
66
- public async createBaseMongoClient(): Promise<MongoClient>
67
- {
68
- const dbUrl = this.opts?.dbUrl || this.configService.get('db_url');
69
- const client = DBService.baseClientConstruct(dbUrl);
70
-
71
- await client.connect();
72
-
73
- return client;
74
-
75
- }
76
-
77
- public async createBaseMongoClientDB(): Promise<[MongoClient, Db]>
78
- {
79
- const dbName = this.opts?.dbName || this.configService.get('db_name');
80
- const client = await this.createBaseMongoClient();
81
- return [client, client.db(dbName)];
82
- }
83
-
84
- public async cloneDatabase(source: string, target: string): Promise<void> {
85
- const client = await this.createBaseMongoClient();
86
-
87
- // Source and target DB
88
- const sourceDb = client.db(source);
89
- const targetDb = client.db(target);
90
-
91
- // Get all collections from source DB
92
- const collections = await sourceDb.listCollections().toArray();
93
-
94
- // Loop over all collections and copy them to the target DB
95
- for (const collection of collections) {
96
- const docs = await sourceDb.collection(collection.name).find({}).toArray();
97
- await targetDb.collection(collection.name).insertMany(docs);
98
- }
99
-
100
- await client.close();
101
- }
102
-
103
- async watchCollection(collectionName: string, preRun: () => void): Promise<any>
104
- {
105
- const [client, db] = await this.createBaseMongoClientDB();
106
- const collection = db.collection(collectionName);
107
-
108
- const changeStream = collection.watch();
109
- return new Promise((resolve) => {
110
- changeStream.on('change', (change) => {
111
- resolve(change);
112
- });
113
-
114
- preRun();
115
- });
116
- }
117
-
118
- async insert(data: any, collection: string, isTimeSeries: boolean = false) {
119
-
120
- let result: any = data;
121
- // Insert time-series data outside of the transaction
122
-
123
- if(isTimeSeries){
124
- const [client, db] = await this.createBaseMongoClientDB();
125
- const collectionHandler = db.collection(collection);
126
-
127
- const insert = await collectionHandler.insertOne(data);
128
-
129
- result = await this.findOneBy(collection, { id: insert.insertedId.toString() });
130
- return result;
131
- }
132
-
133
- const prismaCollection = this.getCollectionHandler(collection);
134
-
135
- result = await prismaCollection.create({ data });
136
-
137
- return await this.findOneBy(collection, { id: result.id });
138
- }
139
-
140
- async update(data: any, collection: string): Promise<IModel>
141
- {
142
- const model_id: string = data.id;
143
- delete data['id'];
144
-
145
- const prismaCollection = this.getCollectionHandler(collection);
146
-
147
- await prismaCollection.update({
148
- where: {
149
- id: model_id,
150
- },
151
- data: data,
152
- });
153
-
154
-
155
- return await this.findOneBy(collection, { id: model_id });
156
- }
157
-
158
-
159
- async findOneBy(collection: string, conditions: any, fields: string[] | null = null, ordering: { [fieldName: string]: string } = null, allowRelations: boolean = true): Promise<IModel|null>
160
- {
161
- const params: any = { where: conditions };
162
-
163
- if(fields){
164
- params.select = {};
165
- fields.forEach((fieldName: string) => {
166
- params.select[fieldName] = true;
167
- });
168
- }
169
-
170
- if(ordering){
171
- params.orderBy = ordering;
172
- }
173
-
174
- const retData = await this.getCollectionHandler(collection).findFirst(params);
175
-
176
- return retData;
177
- }
178
-
179
- async delete(collection: string, conditions: any): Promise<void>
180
- {
181
- await this.getCollectionHandler(collection).deleteMany({ where: conditions });
182
- return;
183
- }
184
-
185
- async findBy(
186
- collection: string,
187
- conditions: any,
188
- fields: string[] | null = null,
189
- ordering: { [fieldName: string]: string } = null,
190
- pagination: IPaginationParams = null): Promise<IModel[]>
191
- {
192
- const params: any ={ where: conditions };
193
-
194
- if(fields){
195
- params.select = {};
196
- fields.forEach((fieldName: string) => {
197
- params.select[fieldName] = true;
198
- });
199
- }
200
-
201
- if(ordering){
202
- params.orderBy = ordering;
203
- }
204
-
205
- if(pagination){
206
- const perPage = pagination.per_page || 50;
207
- params.skip = (pagination.page || 0) * perPage;
208
- params.take = perPage;
209
- }
210
-
211
- const retData = await this.getCollectionHandler(collection).findMany(params);
212
-
213
- return retData;
214
- }
215
-
216
- async collectionExists(collection_name: string): Promise<boolean>
217
- {
218
- const dbUrl = this.opts?.dbUrl || this.configService.get('db_url');
219
- const client = new MongoClient(dbUrl);
220
-
221
- try {
222
- await client.connect();
223
-
224
- const db = client.db(this.configService.get('db_name'));
225
-
226
- const collections = await db.listCollections().toArray();
227
- const existingCollectionNames = collections.map((collection) => collection.name);
228
-
229
- return existingCollectionNames.includes(collection_name);
230
- } catch (error) {
231
- console.error('Error connecting to MongoDB:', error);
232
-
233
- throw error;
234
- }
235
- }
236
-
237
- async createTimeSeriesCollection(collection_name: string): Promise<Collection<ITimeSeries>>
238
- {
239
- try {
240
- const [client, db] = await this.createBaseMongoClientDB();
241
-
242
- // Create a time series collection
243
- const options = {
244
- timeseries: {
245
- timeField: 'timestamp', // Replace with your timestamp field
246
- metaField: 'params' // Replace with your metadata field
247
- }
248
- };
249
-
250
- await db.createCollection(collection_name, options); // Replace with your collection name
251
-
252
- return db.collection(collection_name);
253
-
254
- } catch (error) {
255
- console.error('Error connecting to MongoDB:', error);
256
-
257
- throw error;
258
- }
259
- }
260
-
261
- private getCollectionHandler(collection: string): any
262
- {
263
- if(!this.client || !this.connected){
264
- this.connectToDB();
265
- }
266
-
267
- return (this.client[collection as keyof PrismaClient] as any);
268
- }
269
-
270
- private setOpts(opts: IDBClientCreate = null): this
271
- {
272
- this.opts = opts;
273
- return this;
274
- }
275
- }
276
-
277
- export { DBService, IDBClientCreate };
1
+ import { PrismaClient } from '@prisma/client';
2
+ import { Collection, Db, MongoClient } from 'mongodb';
3
+ import {ITimeSeries} from '../types/ITimeSeries';
4
+ import { IModel } from '../models/interfaces/IModel';
5
+ import chalk from 'chalk';
6
+ import { IDbConfigHandler } from '../types/DbConfigHandler';
7
+ import { IPaginationParams } from '../types/FindParams';
8
+
9
+ interface IDBClientCreate {
10
+ dbUrl?: string;
11
+ dbName?: string;
12
+ }
13
+
14
+ class DBService {
15
+ private client: PrismaClient;
16
+ private opts: IDBClientCreate = null;
17
+ private connected = false;
18
+
19
+ constructor(private configService: IDbConfigHandler){}
20
+
21
+ private connectToDB(opts: IDBClientCreate = null) {
22
+ if(opts){
23
+ this.opts = opts;
24
+ }else{
25
+ this.opts = {
26
+ dbUrl: this.configService.get('db_url'),
27
+ dbName: this.configService.get('db_name'),
28
+ };
29
+ }
30
+
31
+ if(!this.opts.dbUrl){
32
+ console.log(chalk.red('No database config set in @rws-framework/db'));
33
+
34
+ return;
35
+ }
36
+
37
+ try{
38
+ this.client = new PrismaClient({
39
+ datasources: {
40
+ db: {
41
+ url: this.opts.dbUrl
42
+ },
43
+ },
44
+ });
45
+
46
+ this.connected = true;
47
+ } catch (e: Error | any){
48
+ console.error(e);
49
+
50
+ throw new Error('PRISMA CONNECTION ERROR');
51
+ }
52
+ }
53
+
54
+ reconnect(opts: IDBClientCreate = null)
55
+ {
56
+ this.connectToDB(opts);
57
+ }
58
+
59
+ static baseClientConstruct(dbUrl: string): MongoClient
60
+ {
61
+ const client = new MongoClient(dbUrl);
62
+
63
+ return client;
64
+ }
65
+
66
+ public async createBaseMongoClient(): Promise<MongoClient>
67
+ {
68
+ const dbUrl = this.opts?.dbUrl || this.configService.get('db_url');
69
+ const client = DBService.baseClientConstruct(dbUrl);
70
+
71
+ await client.connect();
72
+
73
+ return client;
74
+
75
+ }
76
+
77
+ public async createBaseMongoClientDB(): Promise<[MongoClient, Db]>
78
+ {
79
+ const dbName = this.opts?.dbName || this.configService.get('db_name');
80
+ const client = await this.createBaseMongoClient();
81
+ return [client, client.db(dbName)];
82
+ }
83
+
84
+ public async cloneDatabase(source: string, target: string): Promise<void> {
85
+ const client = await this.createBaseMongoClient();
86
+
87
+ // Source and target DB
88
+ const sourceDb = client.db(source);
89
+ const targetDb = client.db(target);
90
+
91
+ // Get all collections from source DB
92
+ const collections = await sourceDb.listCollections().toArray();
93
+
94
+ // Loop over all collections and copy them to the target DB
95
+ for (const collection of collections) {
96
+ const docs = await sourceDb.collection(collection.name).find({}).toArray();
97
+ await targetDb.collection(collection.name).insertMany(docs);
98
+ }
99
+
100
+ await client.close();
101
+ }
102
+
103
+ async watchCollection(collectionName: string, preRun: () => void): Promise<any>
104
+ {
105
+ const [client, db] = await this.createBaseMongoClientDB();
106
+ const collection = db.collection(collectionName);
107
+
108
+ const changeStream = collection.watch();
109
+ return new Promise((resolve) => {
110
+ changeStream.on('change', (change) => {
111
+ resolve(change);
112
+ });
113
+
114
+ preRun();
115
+ });
116
+ }
117
+
118
+ async insert(data: any, collection: string, isTimeSeries: boolean = false) {
119
+
120
+ let result: any = data;
121
+ // Insert time-series data outside of the transaction
122
+
123
+ if(isTimeSeries){
124
+ const [client, db] = await this.createBaseMongoClientDB();
125
+ const collectionHandler = db.collection(collection);
126
+
127
+ const insert = await collectionHandler.insertOne(data);
128
+
129
+ result = await this.findOneBy(collection, { id: insert.insertedId.toString() });
130
+ return result;
131
+ }
132
+
133
+ const prismaCollection = this.getCollectionHandler(collection);
134
+
135
+ result = await prismaCollection.create({ data });
136
+
137
+ return await this.findOneBy(collection, { id: result.id });
138
+ }
139
+
140
+ async update(data: any, collection: string): Promise<IModel>
141
+ {
142
+ const model_id: string = data.id;
143
+ delete data['id'];
144
+
145
+ const prismaCollection = this.getCollectionHandler(collection);
146
+
147
+ await prismaCollection.update({
148
+ where: {
149
+ id: model_id,
150
+ },
151
+ data: data,
152
+ });
153
+
154
+
155
+ return await this.findOneBy(collection, { id: model_id });
156
+ }
157
+
158
+
159
+ async findOneBy(collection: string, conditions: any, fields: string[] | null = null, ordering: { [fieldName: string]: string } = null, allowRelations: boolean = true): Promise<IModel|null>
160
+ {
161
+ const params: any = { where: conditions };
162
+
163
+ if(fields){
164
+ params.select = {};
165
+ fields.forEach((fieldName: string) => {
166
+ params.select[fieldName] = true;
167
+ });
168
+ }
169
+
170
+ if(ordering){
171
+ params.orderBy = ordering;
172
+ }
173
+
174
+ const retData = await this.getCollectionHandler(collection).findFirst(params);
175
+
176
+ return retData;
177
+ }
178
+
179
+ async delete(collection: string, conditions: any): Promise<void>
180
+ {
181
+ await this.getCollectionHandler(collection).deleteMany({ where: conditions });
182
+ return;
183
+ }
184
+
185
+ async findBy(
186
+ collection: string,
187
+ conditions: any,
188
+ fields: string[] | null = null,
189
+ ordering: { [fieldName: string]: string } = null,
190
+ pagination: IPaginationParams = null): Promise<IModel[]>
191
+ {
192
+ const params: any ={ where: conditions };
193
+
194
+ if(fields){
195
+ params.select = {};
196
+ fields.forEach((fieldName: string) => {
197
+ params.select[fieldName] = true;
198
+ });
199
+ }
200
+
201
+ if(ordering){
202
+ params.orderBy = ordering;
203
+ }
204
+
205
+ if(pagination){
206
+ const perPage = pagination.per_page || 50;
207
+ params.skip = (pagination.page || 0) * perPage;
208
+ params.take = perPage;
209
+ }
210
+
211
+ const retData = await this.getCollectionHandler(collection).findMany(params);
212
+
213
+ return retData;
214
+ }
215
+
216
+ async collectionExists(collection_name: string): Promise<boolean>
217
+ {
218
+ const dbUrl = this.opts?.dbUrl || this.configService.get('db_url');
219
+ const client = new MongoClient(dbUrl);
220
+
221
+ try {
222
+ await client.connect();
223
+
224
+ const db = client.db(this.configService.get('db_name'));
225
+
226
+ const collections = await db.listCollections().toArray();
227
+ const existingCollectionNames = collections.map((collection) => collection.name);
228
+
229
+ return existingCollectionNames.includes(collection_name);
230
+ } catch (error) {
231
+ console.error('Error connecting to MongoDB:', error);
232
+
233
+ throw error;
234
+ }
235
+ }
236
+
237
+ async createTimeSeriesCollection(collection_name: string): Promise<Collection<ITimeSeries>>
238
+ {
239
+ try {
240
+ const [client, db] = await this.createBaseMongoClientDB();
241
+
242
+ // Create a time series collection
243
+ const options = {
244
+ timeseries: {
245
+ timeField: 'timestamp', // Replace with your timestamp field
246
+ metaField: 'params' // Replace with your metadata field
247
+ }
248
+ };
249
+
250
+ await db.createCollection(collection_name, options); // Replace with your collection name
251
+
252
+ return db.collection(collection_name);
253
+
254
+ } catch (error) {
255
+ console.error('Error connecting to MongoDB:', error);
256
+
257
+ throw error;
258
+ }
259
+ }
260
+
261
+ private getCollectionHandler(collection: string): any
262
+ {
263
+ if(!this.client || !this.connected){
264
+ this.connectToDB();
265
+ }
266
+
267
+ return (this.client[collection as keyof PrismaClient] as any);
268
+ }
269
+
270
+ private setOpts(opts: IDBClientCreate = null): this
271
+ {
272
+ this.opts = opts;
273
+ return this;
274
+ }
275
+ }
276
+
277
+ export { DBService, IDBClientCreate };
@@ -1,17 +1,17 @@
1
- import { OpModelType } from "../models/interfaces/OpModelType";
2
-
3
- export interface IDbConfigParams {
4
- db_url?: string;
5
- db_name?: string;
6
- db_type?: 'mongodb' | 'mysql' | 'sqlite';
7
- db_models?: OpModelType<any>[]
8
- }
9
-
10
- export interface IdGeneratorOptions {
11
- useUuid?: boolean; // dla MySQL
12
- customType?: string; // dla custom typów
13
- }
14
-
15
- export interface IDbConfigHandler {
16
- get<K extends keyof IDbConfigParams>(key: K): IDbConfigParams[K];
17
- }
1
+ import { OpModelType } from "../models/interfaces/OpModelType";
2
+
3
+ export interface IDbConfigParams {
4
+ db_url?: string;
5
+ db_name?: string;
6
+ db_type?: 'mongodb' | 'mysql' | 'sqlite' | 'postgresql' | 'postgres';
7
+ db_models?: OpModelType<any>[]
8
+ }
9
+
10
+ export interface IdGeneratorOptions {
11
+ useUuid?: boolean; // dla MySQL
12
+ customType?: string; // dla custom typów
13
+ }
14
+
15
+ export interface IDbConfigHandler {
16
+ get<K extends keyof IDbConfigParams>(key: K): IDbConfigParams[K];
17
+ }
@@ -1,13 +1,13 @@
1
- export type FindByType = {
2
- conditions?: any
3
- ordering?: { [fieldName: string]: string }
4
- fields?: string[]
5
- allowRelations?: boolean
6
- fullData?: boolean
7
- pagination?: IPaginationParams
8
- }
9
-
10
- export interface IPaginationParams {
11
- page: number,
12
- per_page?: number
13
- }
1
+ export type FindByType = {
2
+ conditions?: any
3
+ ordering?: { [fieldName: string]: string }
4
+ fields?: string[]
5
+ allowRelations?: boolean
6
+ fullData?: boolean
7
+ pagination?: IPaginationParams
8
+ }
9
+
10
+ export interface IPaginationParams {
11
+ page: number,
12
+ per_page?: number
13
+ }
@@ -1,3 +1,3 @@
1
- export interface IRWSModel {
2
- id?: string
1
+ export interface IRWSModel {
2
+ id?: string | number
3
3
  }
@@ -1,6 +1,6 @@
1
- export interface ITimeSeries {
2
- value: number,
3
- timestamp?: Date;
4
- params?: any;
5
- time_tracker_id?: string
1
+ export interface ITimeSeries {
2
+ value: number,
3
+ timestamp?: Date;
4
+ params?: any;
5
+ time_tracker_id?: string
6
6
  }