@rws-framework/db 2.0.2 → 2.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.
@@ -0,0 +1,10 @@
1
+ import 'reflect-metadata';
2
+ import { RWSModel, OpModelType } from '../models/_model';
3
+ interface InverseRelationOpts {
4
+ key: string;
5
+ inversionModel: OpModelType<RWSModel<any>>;
6
+ foreignKey: string;
7
+ }
8
+ declare function InverseRelation(inversionModel: () => OpModelType<RWSModel<any>>, sourceModel: () => OpModelType<RWSModel<any>>, foreignKey?: string): (target: any, key: string) => void;
9
+ export default InverseRelation;
10
+ export { InverseRelationOpts };
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ require("reflect-metadata");
4
+ function InverseRelation(inversionModel, sourceModel, foreignKey = null) {
5
+ return function (target, key) {
6
+ // Store the promise in metadata immediately
7
+ const metadataPromise = Promise.resolve().then(() => {
8
+ const model = inversionModel();
9
+ const source = sourceModel();
10
+ const metaOpts = {
11
+ key,
12
+ inversionModel: model,
13
+ foreignKey: foreignKey ? foreignKey : `${source._collection}_id`
14
+ };
15
+ return metaOpts;
16
+ });
17
+ // Store both the promise and the key information
18
+ Reflect.defineMetadata(`InverseRelation:${key}`, {
19
+ promise: metadataPromise,
20
+ key
21
+ }, target);
22
+ };
23
+ }
24
+ exports.default = InverseRelation;
@@ -0,0 +1,8 @@
1
+ import 'reflect-metadata';
2
+ interface InverseTimeSeriesOpts {
3
+ timeSeriesModel: string;
4
+ hydrationField: string;
5
+ }
6
+ declare function InverseTimeSeries(timeSeriesModel: string, hydrationField: string): (target: any, key: string) => void;
7
+ export default InverseTimeSeries;
8
+ export { InverseTimeSeriesOpts };
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ require("reflect-metadata");
4
+ function InverseTimeSeries(timeSeriesModel, hydrationField) {
5
+ const metaOpts = {
6
+ timeSeriesModel: timeSeriesModel,
7
+ hydrationField: hydrationField
8
+ };
9
+ return function (target, key) {
10
+ Reflect.defineMetadata(`InverseTimeSeries:${key}`, metaOpts, target);
11
+ };
12
+ }
13
+ exports.default = InverseTimeSeries;
@@ -0,0 +1,12 @@
1
+ import 'reflect-metadata';
2
+ import { RWSModel, OpModelType } from '../models/_model';
3
+ interface IRelationOpts {
4
+ required?: boolean;
5
+ key?: string;
6
+ relationField?: string;
7
+ relatedToField?: string;
8
+ relatedTo: OpModelType<RWSModel<any>>;
9
+ }
10
+ declare function Relation(theModel: () => OpModelType<RWSModel<any>>, required?: boolean, relationField?: string, relatedToField?: string): (target: any, key: string) => void;
11
+ export default Relation;
12
+ export { IRelationOpts };
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ require("reflect-metadata");
4
+ function Relation(theModel, required = false, relationField = null, relatedToField = 'id') {
5
+ return function (target, key) {
6
+ // Store the promise in metadata immediately
7
+ const metadataPromise = Promise.resolve().then(() => {
8
+ const relatedTo = theModel();
9
+ const metaOpts = { required, relatedTo, relatedToField };
10
+ if (!relationField) {
11
+ metaOpts.relationField = relatedTo._collection + '_id';
12
+ }
13
+ else {
14
+ metaOpts.relationField = relationField;
15
+ }
16
+ metaOpts.key = key;
17
+ return metaOpts;
18
+ });
19
+ // Store both the promise and the key information
20
+ Reflect.defineMetadata(`Relation:${key}`, {
21
+ promise: metadataPromise,
22
+ key
23
+ }, target);
24
+ };
25
+ }
26
+ exports.default = Relation;
@@ -0,0 +1,17 @@
1
+ import 'reflect-metadata';
2
+ import { OpModelType } from '../models/_model';
3
+ interface ITrackerOpts {
4
+ required?: boolean;
5
+ relationField?: string;
6
+ relatedToField?: string;
7
+ relatedTo?: OpModelType<any>;
8
+ inversionModel?: OpModelType<any>;
9
+ relationName?: string;
10
+ }
11
+ interface IMetaOpts extends ITrackerOpts {
12
+ type: any;
13
+ tags: string[];
14
+ }
15
+ declare function TrackType(type: any, opts?: ITrackerOpts | null, tags?: string[]): (target: any, key: string) => void;
16
+ export default TrackType;
17
+ export { IMetaOpts, ITrackerOpts };
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ require("reflect-metadata");
4
+ function TrackType(type, opts = null, tags = []) {
5
+ if (!opts) {
6
+ opts = {
7
+ required: false
8
+ };
9
+ }
10
+ const required = opts.required;
11
+ const metaOpts = { type, tags, required };
12
+ if (opts.relatedToField && opts.relatedTo) {
13
+ metaOpts.relatedToField = opts.relatedToField;
14
+ metaOpts.relatedTo = opts.relatedTo;
15
+ if (!opts.relationField) {
16
+ metaOpts.relationField = opts.relatedTo + '_id';
17
+ }
18
+ else {
19
+ metaOpts.relationField = opts.relationField;
20
+ }
21
+ }
22
+ if (opts.inversionModel) {
23
+ metaOpts.inversionModel = opts.inversionModel;
24
+ }
25
+ //const resolvedType = typeof type === 'function' ? type() : type;
26
+ if (type._collection) {
27
+ metaOpts.type = type;
28
+ }
29
+ return function (target, key) {
30
+ Reflect.defineMetadata(`TrackType:${key}`, metaOpts, target);
31
+ };
32
+ }
33
+ exports.default = TrackType;
@@ -0,0 +1,5 @@
1
+ import InverseRelation from './InverseRelation';
2
+ import Relation from './Relation';
3
+ import TrackType, { IMetaOpts } from './TrackType';
4
+ import InverseTimeSeries from './InverseTimeSeries';
5
+ export { InverseRelation, Relation, TrackType, InverseTimeSeries, IMetaOpts };
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.InverseTimeSeries = exports.TrackType = exports.Relation = exports.InverseRelation = void 0;
7
+ const InverseRelation_1 = __importDefault(require("./InverseRelation"));
8
+ exports.InverseRelation = InverseRelation_1.default;
9
+ const Relation_1 = __importDefault(require("./Relation"));
10
+ exports.Relation = Relation_1.default;
11
+ const TrackType_1 = __importDefault(require("./TrackType"));
12
+ exports.TrackType = TrackType_1.default;
13
+ const InverseTimeSeries_1 = __importDefault(require("./InverseTimeSeries"));
14
+ exports.InverseTimeSeries = InverseTimeSeries_1.default;
@@ -0,0 +1,8 @@
1
+ import { IDbConfigHandler } from '../types/DbConfigHandler';
2
+ import { OpModelType } from '../models/_model';
3
+ import { DBService } from '../services/DBService';
4
+ export declare class DbHelper {
5
+ static installPrisma(configService: IDbConfigHandler, dbService: DBService, leaveFile?: boolean): Promise<void>;
6
+ static generateModelSections(model: OpModelType<any>): Promise<string>;
7
+ static toConfigCase(modelType: any): string;
8
+ }
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.DbHelper = void 0;
7
+ const console_1 = require("@rws-framework/console");
8
+ const chalk_1 = __importDefault(require("chalk"));
9
+ const path_1 = __importDefault(require("path"));
10
+ const fs_1 = __importDefault(require("fs"));
11
+ const _model_1 = require("../models/_model");
12
+ const TimeSeriesModel_1 = __importDefault(require("../models/TimeSeriesModel"));
13
+ const log = console.log;
14
+ const workspaceRoot = console_1.rwsPath.findRootWorkspacePath();
15
+ const moduleDir = path_1.default.resolve(workspaceRoot, 'node_modules', '@rws-framework', 'db');
16
+ class DbHelper {
17
+ static async installPrisma(configService, dbService, leaveFile = false) {
18
+ const dbUrl = configService.get('mongo_url');
19
+ const dbType = 'mongodb';
20
+ let template = `generator client {\n
21
+ provider = "prisma-client-js"\n
22
+ }\n\n`;
23
+ template += `\ndatasource db {\n
24
+ provider = "${dbType}"\n
25
+ url = env("DATABASE_URL")\n
26
+ }\n\n`;
27
+ const dbModels = configService.get('db_models');
28
+ if (dbModels) {
29
+ for (const model of dbModels) {
30
+ const modelSection = await DbHelper.generateModelSections(model);
31
+ template += '\n\n' + modelSection;
32
+ log('RWS SCHEMA BUILD', chalk_1.default.blue('Building DB Model'), model.name);
33
+ if (_model_1.RWSModel.isSubclass(model, TimeSeriesModel_1.default)) {
34
+ dbService.collectionExists(model._collection).then((exists) => {
35
+ if (exists) {
36
+ return;
37
+ }
38
+ log(chalk_1.default.green('[RWS Init]') + ` creating TimeSeries type collection from ${model} model`);
39
+ dbService.createTimeSeriesCollection(model._collection);
40
+ });
41
+ }
42
+ }
43
+ const schemaDir = path_1.default.join(moduleDir, 'prisma');
44
+ const schemaPath = path_1.default.join(schemaDir, 'schema.prisma');
45
+ if (!fs_1.default.existsSync(schemaDir)) {
46
+ fs_1.default.mkdirSync(schemaDir);
47
+ }
48
+ if (fs_1.default.existsSync(schemaPath)) {
49
+ fs_1.default.unlinkSync(schemaPath);
50
+ }
51
+ fs_1.default.writeFileSync(schemaPath, template);
52
+ process.env.DB_URL = dbUrl;
53
+ const endPrisma = 'npx prisma';
54
+ await console_1.rwsShell.runCommand(`${endPrisma} generate --schema=${schemaPath}`, process.cwd());
55
+ // leaveFile = true;
56
+ log(chalk_1.default.green('[RWS Init]') + ' prisma schema generated from ', schemaPath);
57
+ if (!leaveFile) {
58
+ fs_1.default.unlinkSync(schemaPath);
59
+ }
60
+ }
61
+ }
62
+ static async generateModelSections(model) {
63
+ let section = '';
64
+ const modelMetadatas = await _model_1.RWSModel.getModelAnnotations(model);
65
+ const modelName = model._collection;
66
+ section += `model ${modelName} {\n`;
67
+ section += '\tid String @map("_id") @id @default(auto()) @db.ObjectId\n';
68
+ for (const key in modelMetadatas) {
69
+ const modelMetadata = modelMetadatas[key].metadata;
70
+ const requiredString = modelMetadata.required ? '' : '?';
71
+ const annotationType = modelMetadatas[key].annotationType;
72
+ if (key === 'id') {
73
+ continue;
74
+ }
75
+ if (annotationType === 'Relation') {
76
+ const relatedModel = modelMetadata.relatedTo;
77
+ // Handle direct relation (many-to-one or one-to-one)
78
+ section += `\t${key} ${relatedModel._collection}${requiredString} @relation("${modelName}_${relatedModel._collection}", fields: [${modelMetadata.relationField}], references: [${modelMetadata.relatedToField}], onDelete: Cascade)\n`;
79
+ section += `\t${modelMetadata.relationField} String${requiredString} @db.ObjectId\n`;
80
+ }
81
+ else if (annotationType === 'InverseRelation') {
82
+ // Handle inverse relation (one-to-many or one-to-one)
83
+ section += `\t${key} ${modelMetadata.inversionModel._collection}[] @relation("${modelMetadata.inversionModel._collection}_${modelName}")\n`;
84
+ }
85
+ else if (annotationType === 'InverseTimeSeries') {
86
+ section += `\t${key} String[] @db.ObjectId\n`;
87
+ }
88
+ else if (annotationType === 'TrackType') {
89
+ const tags = modelMetadata.tags.map((item) => '@' + item);
90
+ section += `\t${key} ${DbHelper.toConfigCase(modelMetadata)}${requiredString} ${tags.join(' ')}\n`;
91
+ }
92
+ }
93
+ section += '}\n';
94
+ return section;
95
+ }
96
+ static toConfigCase(modelType) {
97
+ const type = modelType.type;
98
+ const input = type.name;
99
+ if (input == 'Number') {
100
+ return 'Int';
101
+ }
102
+ if (input == 'Object') {
103
+ return 'Json';
104
+ }
105
+ if (input == 'Date') {
106
+ return 'DateTime';
107
+ }
108
+ const firstChar = input.charAt(0).toUpperCase();
109
+ const restOfString = input.slice(1);
110
+ return firstChar + restOfString;
111
+ }
112
+ }
113
+ exports.DbHelper = DbHelper;
@@ -0,0 +1,4 @@
1
+ export declare class FieldsHelper {
2
+ private constructor();
3
+ static getAllClassFields(target: any): string[];
4
+ }
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FieldsHelper = void 0;
4
+ class FieldsHelper {
5
+ constructor() {
6
+ throw new Error(`Class ${this.constructor.name} cannot be instanced.`);
7
+ }
8
+ static getAllClassFields(target) {
9
+ // Get instance properties
10
+ const instanceFields = Object.getOwnPropertyNames(target.prototype);
11
+ // Get static properties
12
+ const staticFields = Object.getOwnPropertyNames(target);
13
+ // Get decorated properties using Reflect metadata if available
14
+ const decoratedFields = Reflect.getMetadataKeys(target.prototype) || [];
15
+ // Combine all fields and remove duplicates and methods
16
+ const allFields = new Set([
17
+ ...instanceFields,
18
+ ...staticFields,
19
+ ...decoratedFields
20
+ ]);
21
+ // Filter out constructor and methods
22
+ return Array.from(allFields).filter(field => {
23
+ // Remove constructor
24
+ if (field === 'constructor')
25
+ return false;
26
+ // Remove methods
27
+ const descriptor = Object.getOwnPropertyDescriptor(target.prototype, field);
28
+ if (descriptor && typeof descriptor.value === 'function')
29
+ return false;
30
+ return true;
31
+ });
32
+ }
33
+ ;
34
+ }
35
+ exports.FieldsHelper = FieldsHelper;
@@ -0,0 +1,11 @@
1
+ import { DBService } from "./services/DBService";
2
+ import { RWSModel, OpModelType } from "./models/_model";
3
+ import TimeSeriesModel from './models/TimeSeriesModel';
4
+ import { InverseRelation, Relation, TrackType, InverseTimeSeries, IMetaOpts } from './decorators';
5
+ import { DbHelper } from './helper/DbHelper';
6
+ import { FieldsHelper } from './helper/FieldsHelper';
7
+ import type { FindByType } from './types/FindParams';
8
+ import type { ITimeSeries } from './types/ITimeSeries';
9
+ import type { IDbConfigHandler } from './types/DbConfigHandler';
10
+ import type { IRWSModel } from './types/IRWSModel';
11
+ export { OpModelType, RWSModel, IRWSModel, IMetaOpts, DBService, FindByType, TimeSeriesModel, ITimeSeries, IDbConfigHandler, InverseRelation, Relation, TrackType, InverseTimeSeries, DbHelper, FieldsHelper };
package/dist/index.js ADDED
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.FieldsHelper = exports.DbHelper = exports.InverseTimeSeries = exports.TrackType = exports.Relation = exports.InverseRelation = exports.TimeSeriesModel = exports.DBService = exports.RWSModel = void 0;
7
+ const DBService_1 = require("./services/DBService");
8
+ Object.defineProperty(exports, "DBService", { enumerable: true, get: function () { return DBService_1.DBService; } });
9
+ const _model_1 = require("./models/_model");
10
+ Object.defineProperty(exports, "RWSModel", { enumerable: true, get: function () { return _model_1.RWSModel; } });
11
+ const TimeSeriesModel_1 = __importDefault(require("./models/TimeSeriesModel"));
12
+ exports.TimeSeriesModel = TimeSeriesModel_1.default;
13
+ const decorators_1 = require("./decorators");
14
+ Object.defineProperty(exports, "InverseRelation", { enumerable: true, get: function () { return decorators_1.InverseRelation; } });
15
+ Object.defineProperty(exports, "Relation", { enumerable: true, get: function () { return decorators_1.Relation; } });
16
+ Object.defineProperty(exports, "TrackType", { enumerable: true, get: function () { return decorators_1.TrackType; } });
17
+ Object.defineProperty(exports, "InverseTimeSeries", { enumerable: true, get: function () { return decorators_1.InverseTimeSeries; } });
18
+ const DbHelper_1 = require("./helper/DbHelper");
19
+ Object.defineProperty(exports, "DbHelper", { enumerable: true, get: function () { return DbHelper_1.DbHelper; } });
20
+ const FieldsHelper_1 = require("./helper/FieldsHelper");
21
+ Object.defineProperty(exports, "FieldsHelper", { enumerable: true, get: function () { return FieldsHelper_1.FieldsHelper; } });
@@ -0,0 +1,7 @@
1
+ import { RWSModel } from './_model';
2
+ export default class TimeSeriesModel<ChildClass> extends RWSModel<TimeSeriesModel<ChildClass>> {
3
+ value: number;
4
+ timestamp: Date;
5
+ params: any;
6
+ constructor(data?: any);
7
+ }
@@ -0,0 +1,33 @@
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
+ const _model_1 = require("./_model");
13
+ class TimeSeriesModel extends _model_1.RWSModel {
14
+ constructor(data) {
15
+ super(data);
16
+ if (!this.timestamp) {
17
+ this.timestamp = new Date();
18
+ }
19
+ }
20
+ }
21
+ exports.default = TimeSeriesModel;
22
+ __decorate([
23
+ (0, _model_1.TrackType)(Number),
24
+ __metadata("design:type", Number)
25
+ ], TimeSeriesModel.prototype, "value", void 0);
26
+ __decorate([
27
+ (0, _model_1.TrackType)(Date),
28
+ __metadata("design:type", Date)
29
+ ], TimeSeriesModel.prototype, "timestamp", void 0);
30
+ __decorate([
31
+ (0, _model_1.TrackType)(Object),
32
+ __metadata("design:type", Object)
33
+ ], TimeSeriesModel.prototype, "params", void 0);
@@ -0,0 +1,116 @@
1
+ import { DBService } from '../services/DBService';
2
+ import { IRWSModel } from '../types/IRWSModel';
3
+ import { IDbConfigHandler } from '../types/DbConfigHandler';
4
+ import { TrackType, IMetaOpts } from '../decorators';
5
+ import { FindByType } from '../types/FindParams';
6
+ interface IModel {
7
+ [key: string]: any;
8
+ id: string | null;
9
+ save: () => void;
10
+ getCollection: () => string | null;
11
+ configService?: IDbConfigHandler;
12
+ dbService?: DBService;
13
+ }
14
+ interface IRWSModelServices {
15
+ configService?: IDbConfigHandler;
16
+ dbService?: DBService;
17
+ }
18
+ type RelationBindType = {
19
+ connect: {
20
+ id: string;
21
+ };
22
+ };
23
+ type RelOneMetaType<T extends IRWSModel> = {
24
+ [key: string]: {
25
+ required: boolean;
26
+ key?: string;
27
+ model: OpModelType<T>;
28
+ hydrationField: string;
29
+ foreignKey: string;
30
+ };
31
+ };
32
+ type RelManyMetaType<T extends IRWSModel> = {
33
+ [key: string]: {
34
+ key: string;
35
+ inversionModel: OpModelType<T>;
36
+ foreignKey: string;
37
+ };
38
+ };
39
+ export interface OpModelType<ChildClass> {
40
+ new (data?: any | null): ChildClass;
41
+ services: IRWSModelServices;
42
+ name: string;
43
+ _collection: string;
44
+ _RELATIONS: {
45
+ [key: string]: boolean;
46
+ };
47
+ _CUT_KEYS: string[];
48
+ allModels: OpModelType<any>[];
49
+ loadModels: () => OpModelType<any>[];
50
+ checkForInclusionWithThrow: (className: string) => void;
51
+ checkForInclusion: (className: string) => boolean;
52
+ findOneBy<T extends RWSModel<T>>(this: OpModelType<T>, findParams: FindByType): Promise<T | null>;
53
+ find<T extends RWSModel<T>>(this: OpModelType<T>, id: string, findParams?: Omit<FindByType, 'conditions'>): Promise<T | null>;
54
+ findBy<T extends RWSModel<T>>(this: OpModelType<T>, findParams: FindByType): Promise<T[]>;
55
+ delete<ChildClass extends RWSModel<ChildClass>>(this: OpModelType<ChildClass>, conditions: any): Promise<void>;
56
+ create<T extends RWSModel<T>>(this: OpModelType<T>, data: T): Promise<T>;
57
+ getRelationOneMeta(model: any, classFields: string[]): Promise<RelOneMetaType<IRWSModel>>;
58
+ getRelationManyMeta(model: any, classFields: string[]): Promise<RelManyMetaType<IRWSModel>>;
59
+ getCollection(): string;
60
+ setServices(services: IRWSModelServices): void;
61
+ }
62
+ declare class RWSModel<ChildClass> implements IModel {
63
+ static services: IRWSModelServices;
64
+ [key: string]: any;
65
+ id: string;
66
+ static _collection: string;
67
+ static _RELATIONS: {};
68
+ static _BANNED_KEYS: string[];
69
+ static allModels: OpModelType<any>[];
70
+ static _CUT_KEYS: string[];
71
+ constructor(data: any);
72
+ checkForInclusionWithThrow(): void;
73
+ static checkForInclusionWithThrow(this: OpModelType<any>, checkModelType: string): void;
74
+ checkForInclusion(): boolean;
75
+ static checkForInclusion(this: OpModelType<any>, checkModelType: string): boolean;
76
+ protected _fill(data: any): RWSModel<ChildClass>;
77
+ protected hasRelation(key: string): boolean;
78
+ protected bindRelation(key: string, relatedModel: RWSModel<any>): RelationBindType;
79
+ _asyncFill(data: any, fullDataMode?: boolean, allowRelations?: boolean): Promise<ChildClass>;
80
+ private getModelScalarFields;
81
+ private getTimeSeriesModelFields;
82
+ private getRelationOneMeta;
83
+ static getRelationOneMeta(model: any, classFields: string[]): Promise<RelOneMetaType<RWSModel<any>>>;
84
+ private getRelationManyMeta;
85
+ static getRelationManyMeta(model: any, classFields: string[]): Promise<RelManyMetaType<RWSModel<any>>>;
86
+ toMongo(): Promise<any>;
87
+ getCollection(): string | null;
88
+ static getCollection(): string | null;
89
+ save(): Promise<this>;
90
+ static getModelAnnotations<T extends unknown>(constructor: new () => T): Promise<Record<string, {
91
+ annotationType: string;
92
+ metadata: any;
93
+ }>>;
94
+ preUpdate(): void;
95
+ postUpdate(): void;
96
+ preCreate(): void;
97
+ postCreate(): void;
98
+ static isSubclass<T extends RWSModel<T>, C extends new () => T>(constructor: C, baseClass: new () => T): boolean;
99
+ hasTimeSeries(): boolean;
100
+ static checkTimeSeries(constructor: any): boolean;
101
+ isDbVariable(variable: string): Promise<boolean>;
102
+ static checkDbVariable(constructor: any, variable: string): Promise<boolean>;
103
+ sanitizeDBData(data: any): any;
104
+ static watchCollection<ChildClass extends RWSModel<ChildClass>>(this: OpModelType<ChildClass>, preRun: () => void): Promise<any>;
105
+ static findOneBy<ChildClass extends RWSModel<ChildClass>>(this: OpModelType<ChildClass>, findParams?: FindByType): Promise<ChildClass | null>;
106
+ static find<ChildClass extends RWSModel<ChildClass>>(this: OpModelType<ChildClass>, id: string, findParams?: Omit<FindByType, 'conditions'>): Promise<ChildClass | null>;
107
+ static findBy<ChildClass extends RWSModel<ChildClass>>(this: OpModelType<ChildClass>, findParams?: FindByType): Promise<ChildClass[]>;
108
+ static delete<ChildClass extends RWSModel<ChildClass>>(this: OpModelType<ChildClass>, conditions: any): Promise<void>;
109
+ delete<ChildClass extends RWSModel<ChildClass>>(): Promise<void>;
110
+ static create<T extends RWSModel<T>>(this: new () => T, data: any): Promise<T>;
111
+ static loadModels(): OpModelType<any>[];
112
+ loadModels(): OpModelType<any>[];
113
+ private checkRelEnabled;
114
+ static setServices(services: IRWSModelServices): void;
115
+ }
116
+ export { IModel, TrackType, IMetaOpts, RWSModel };