@rws-framework/db 2.0.5 → 2.1.0

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
+ export interface IRWSCollectionOpts {
2
+ relations?: {
3
+ [key: string]: boolean;
4
+ };
5
+ }
6
+ export interface IRWSCollectionMeta {
7
+ collectionName: string;
8
+ options?: IRWSCollectionOpts;
9
+ }
10
+ export declare function RWSCollection(collectionName: string, options?: IRWSCollectionOpts): (target: any) => void;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RWSCollection = RWSCollection;
4
+ function RWSCollection(collectionName, options) {
5
+ const metaOpts = { collectionName, options };
6
+ return function (target) {
7
+ target._collection = collectionName;
8
+ Reflect.defineMetadata(`RWSCollection`, metaOpts, target);
9
+ };
10
+ }
package/dist/index.d.ts CHANGED
@@ -8,4 +8,6 @@ import type { FindByType } from './types/FindParams';
8
8
  import type { ITimeSeries } from './types/ITimeSeries';
9
9
  import type { IDbConfigHandler } from './types/DbConfigHandler';
10
10
  import type { IRWSModel } from './types/IRWSModel';
11
- export { OpModelType, RWSModel, IRWSModel, IMetaOpts, DBService, FindByType, TimeSeriesModel, ITimeSeries, IDbConfigHandler, InverseRelation, Relation, TrackType, InverseTimeSeries, DbHelper, FieldsHelper };
11
+ import { RWSCollection, IRWSCollectionMeta, IRWSCollectionOpts } from "./decorators/RWSCollection";
12
+ export type { IRWSCollectionMeta, IRWSCollectionOpts, IRWSModel, IMetaOpts, OpModelType, IDbConfigHandler, ITimeSeries, };
13
+ export { RWSModel, RWSCollection, DBService, FindByType, TimeSeriesModel, InverseRelation, Relation, TrackType, InverseTimeSeries, DbHelper, FieldsHelper };
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
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;
6
+ exports.FieldsHelper = exports.DbHelper = exports.InverseTimeSeries = exports.TrackType = exports.Relation = exports.InverseRelation = exports.TimeSeriesModel = exports.DBService = exports.RWSCollection = exports.RWSModel = void 0;
7
7
  const DBService_1 = require("./services/DBService");
8
8
  Object.defineProperty(exports, "DBService", { enumerable: true, get: function () { return DBService_1.DBService; } });
9
9
  const _model_1 = require("./models/_model");
@@ -19,3 +19,5 @@ const DbHelper_1 = require("./helper/DbHelper");
19
19
  Object.defineProperty(exports, "DbHelper", { enumerable: true, get: function () { return DbHelper_1.DbHelper; } });
20
20
  const FieldsHelper_1 = require("./helper/FieldsHelper");
21
21
  Object.defineProperty(exports, "FieldsHelper", { enumerable: true, get: function () { return FieldsHelper_1.FieldsHelper; } });
22
+ const RWSCollection_1 = require("./decorators/RWSCollection");
23
+ Object.defineProperty(exports, "RWSCollection", { enumerable: true, get: function () { return RWSCollection_1.RWSCollection; } });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rws-framework/db",
3
3
  "private": false,
4
- "version": "2.0.5",
4
+ "version": "2.1.0",
5
5
  "description": "",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -0,0 +1,19 @@
1
+ export interface IRWSCollectionOpts {
2
+ relations?: {
3
+ [key: string]: boolean
4
+ }
5
+ }
6
+
7
+ export interface IRWSCollectionMeta {
8
+ collectionName: string,
9
+ options?: IRWSCollectionOpts
10
+ }
11
+
12
+
13
+ export function RWSCollection(collectionName: string, options?: IRWSCollectionOpts) {
14
+ const metaOpts: IRWSCollectionMeta = { collectionName, options };
15
+ return function(target: any) {
16
+ target._collection = collectionName;
17
+ Reflect.defineMetadata(`RWSCollection`, metaOpts, target);
18
+ };
19
+ }
package/src/index.ts CHANGED
@@ -10,21 +10,25 @@ import type { FindByType } from './types/FindParams';
10
10
  import type { ITimeSeries } from './types/ITimeSeries';
11
11
  import type { IDbConfigHandler } from './types/DbConfigHandler';
12
12
  import type { IRWSModel } from './types/IRWSModel';
13
+ import { RWSCollection, IRWSCollectionMeta, IRWSCollectionOpts } from "./decorators/RWSCollection";
13
14
 
14
-
15
- export {
16
- OpModelType,
17
- RWSModel,
15
+ export type {
16
+ IRWSCollectionMeta, IRWSCollectionOpts,
18
17
  IRWSModel,
19
18
  IMetaOpts,
19
+ OpModelType,
20
+ IDbConfigHandler,
21
+ ITimeSeries,
22
+ }
20
23
 
24
+ export {
25
+ RWSModel,
26
+ RWSCollection,
27
+
21
28
  DBService,
22
29
 
23
30
  FindByType,
24
- TimeSeriesModel,
25
- ITimeSeries,
26
-
27
- IDbConfigHandler,
31
+ TimeSeriesModel,
28
32
 
29
33
  InverseRelation, Relation, TrackType, InverseTimeSeries,
30
34