@samet-it/be-db-common 1.3.1 → 1.3.2

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.
@@ -272,15 +272,19 @@ export declare abstract class DbRepo<CONN extends DbConnectionLike, OPT extends
272
272
  getDim<R extends IdDocLike<ID>>(key: PORTION | KeyValue, dim?: DIMS): Promise<R>;
273
273
  /** @inheritDoc */
274
274
  listDims<R extends IdDocLike<ID>>(keys: Array<PORTION | KeyValue>, dim?: DIMS, ignoreCheck?: boolean): Promise<Array<R>>;
275
+ toPair(doc: ENT): Promise<PAIR>;
275
276
  /** @inheritDoc */
276
277
  getPair(key: PORTION | KeyValue): Promise<PAIR>;
277
278
  /** @inheritDoc */
278
279
  listPairs(keys: Array<PORTION | KeyValue>, ignoreCheck?: boolean): Promise<Array<PAIR>>;
280
+ toView(doc: ENT): Promise<VIEW>;
279
281
  /** @inheritDoc */
280
282
  getView(key: PORTION | KeyValue): Promise<VIEW>;
281
283
  /** @inheritDoc */
282
284
  listViews(keys: Array<PORTION | KeyValue>, ignoreCheck?: boolean): Promise<Array<VIEW>>;
283
285
  /** @inheritDoc */
286
+ toPortion(doc: ENT): Promise<PORTION>;
287
+ /** @inheritDoc */
284
288
  getPortion(key: PORTION | KeyValue): Promise<PORTION>;
285
289
  /** @inheritDoc */
286
290
  listPortions(keys: Array<PORTION | KeyValue>, ignoreCheck?: boolean): Promise<Array<PORTION>>;
@@ -1188,6 +1188,11 @@ class DbRepo {
1188
1188
  }
1189
1189
  // endregion dim
1190
1190
  // region pair
1191
+ toPair(doc) {
1192
+ return __awaiter(this, void 0, void 0, function* () {
1193
+ return this.$toDim(doc, 'pair');
1194
+ });
1195
+ }
1191
1196
  /** @inheritDoc */
1192
1197
  getPair(key) {
1193
1198
  return __awaiter(this, void 0, void 0, function* () {
@@ -1202,6 +1207,11 @@ class DbRepo {
1202
1207
  }
1203
1208
  // endregion pair
1204
1209
  // region view
1210
+ toView(doc) {
1211
+ return __awaiter(this, void 0, void 0, function* () {
1212
+ return this.$toDim(doc, 'view');
1213
+ });
1214
+ }
1205
1215
  /** @inheritDoc */
1206
1216
  getView(key) {
1207
1217
  return __awaiter(this, void 0, void 0, function* () {
@@ -1217,6 +1227,12 @@ class DbRepo {
1217
1227
  // endregion view
1218
1228
  // region portion
1219
1229
  /** @inheritDoc */
1230
+ toPortion(doc) {
1231
+ return __awaiter(this, void 0, void 0, function* () {
1232
+ return this.$toDim(doc, 'portion');
1233
+ });
1234
+ }
1235
+ /** @inheritDoc */
1220
1236
  getPortion(key) {
1221
1237
  return __awaiter(this, void 0, void 0, function* () {
1222
1238
  return this.getDim(key, 'portion');
@@ -662,6 +662,14 @@ export interface DbRepoLike<CONN extends DbConnectionLike, OPT extends DbExecOpt
662
662
  * @return {Promise<Array<IdDocLike>>} - dim objects
663
663
  * */
664
664
  listDims<R extends IdDocLike<ID>>(keys: Array<PORTION | KeyValue>, dim?: DIMS, ignoreCheck?: boolean): Promise<Array<R>>;
665
+ /**
666
+ * Convert document to pair
667
+ *
668
+ * @param {Entity} doc - document
669
+ * @return {Promise<Pair>} - pair object
670
+ * @async
671
+ * */
672
+ toPair(doc: ENT): Promise<PAIR>;
665
673
  /**
666
674
  * Get pair by key (primary or secondary)
667
675
  *
@@ -678,6 +686,14 @@ export interface DbRepoLike<CONN extends DbConnectionLike, OPT extends DbExecOpt
678
686
  * @return {Promise<Array<Pair>>} - pair objects
679
687
  * */
680
688
  listPairs(keys: Array<PORTION | KeyValue>, ignoreCheck?: boolean): Promise<Array<PAIR>>;
689
+ /**
690
+ * Convert document to view
691
+ *
692
+ * @param {Entity} doc - document
693
+ * @return {Promise<View>} - view object
694
+ * @async
695
+ * */
696
+ toView(doc: ENT): Promise<VIEW>;
681
697
  /**
682
698
  * Get view by key (primary or secondary)
683
699
  *
@@ -694,6 +710,14 @@ export interface DbRepoLike<CONN extends DbConnectionLike, OPT extends DbExecOpt
694
710
  * @return {Promise<Array<View>>} - view objects
695
711
  * */
696
712
  listViews(keys: Array<KeyValue>, ignoreCheck?: boolean): Promise<Array<VIEW>>;
713
+ /**
714
+ * Convert document to portion
715
+ *
716
+ * @param {Entity} doc - document
717
+ * @return {Promise<Portion>} - portion object
718
+ * @async
719
+ * */
720
+ toPortion(doc: ENT): Promise<PORTION>;
697
721
  /**
698
722
  * Get portion by key (primary or secondary)
699
723
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@samet-it/be-db-common",
3
- "version": "1.3.1",
3
+ "version": "1.3.2",
4
4
  "description": "Backend DB Common",
5
5
  "repository": {
6
6
  "type": "git",