@common-stack/store-mongo 0.1.12 → 0.1.21
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/README.md +2 -2
- package/lib/dataloaders/bulk-dataloader.d.ts +7 -0
- package/lib/dataloaders/index.d.ts +1 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +101 -9
- package/lib/index.js.map +1 -1
- package/lib/interfaces/dataloaders.d.ts +2 -0
- package/lib/interfaces/index.d.ts +1 -0
- package/package.json +4 -3
- package/CHANGELOG.md +0 -176
package/README.md
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './bulk-dataloader';
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -122,12 +122,76 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
122
122
|
o[k2] = m[k];
|
|
123
123
|
}));
|
|
124
124
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
125
|
-
for (var p in m) if (p !== "default" && !
|
|
125
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
126
126
|
};
|
|
127
127
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
128
128
|
__exportStar(__webpack_require__(/*! ./default-options */ "./src/constants/default-options.ts"), exports);
|
|
129
129
|
|
|
130
130
|
|
|
131
|
+
/***/ }),
|
|
132
|
+
|
|
133
|
+
/***/ "./src/dataloaders/bulk-dataloader.ts":
|
|
134
|
+
/*!********************************************!*\
|
|
135
|
+
!*** ./src/dataloaders/bulk-dataloader.ts ***!
|
|
136
|
+
\********************************************/
|
|
137
|
+
/*! no static exports found */
|
|
138
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
139
|
+
|
|
140
|
+
"use strict";
|
|
141
|
+
|
|
142
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
143
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
144
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
145
|
+
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;
|
|
146
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
147
|
+
};
|
|
148
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
149
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
150
|
+
};
|
|
151
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
152
|
+
exports.BulkDataLoader = void 0;
|
|
153
|
+
const DataLoader = __webpack_require__(/*! dataloader */ "dataloader");
|
|
154
|
+
const inversify_1 = __webpack_require__(/*! inversify */ "inversify");
|
|
155
|
+
let BulkDataLoader = class BulkDataLoader extends DataLoader {
|
|
156
|
+
constructor(service) {
|
|
157
|
+
super(async (ids) => {
|
|
158
|
+
const data = await service.getByIds(ids);
|
|
159
|
+
return ids.map((id) => data.find((record) => record.id === id));
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
BulkDataLoader = __decorate([
|
|
164
|
+
inversify_1.injectable(),
|
|
165
|
+
__param(0, inversify_1.unmanaged())
|
|
166
|
+
], BulkDataLoader);
|
|
167
|
+
exports.BulkDataLoader = BulkDataLoader;
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
/***/ }),
|
|
171
|
+
|
|
172
|
+
/***/ "./src/dataloaders/index.ts":
|
|
173
|
+
/*!**********************************!*\
|
|
174
|
+
!*** ./src/dataloaders/index.ts ***!
|
|
175
|
+
\**********************************/
|
|
176
|
+
/*! no static exports found */
|
|
177
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
178
|
+
|
|
179
|
+
"use strict";
|
|
180
|
+
|
|
181
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
182
|
+
if (k2 === undefined) k2 = k;
|
|
183
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
184
|
+
}) : (function(o, m, k, k2) {
|
|
185
|
+
if (k2 === undefined) k2 = k;
|
|
186
|
+
o[k2] = m[k];
|
|
187
|
+
}));
|
|
188
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
189
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
190
|
+
};
|
|
191
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
192
|
+
__exportStar(__webpack_require__(/*! ./bulk-dataloader */ "./src/dataloaders/bulk-dataloader.ts"), exports);
|
|
193
|
+
|
|
194
|
+
|
|
131
195
|
/***/ }),
|
|
132
196
|
|
|
133
197
|
/***/ "./src/helpers/index.ts":
|
|
@@ -147,7 +211,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
147
211
|
o[k2] = m[k];
|
|
148
212
|
}));
|
|
149
213
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
150
|
-
for (var p in m) if (p !== "default" && !
|
|
214
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
151
215
|
};
|
|
152
216
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
153
217
|
__exportStar(__webpack_require__(/*! ./mongoose-connection */ "./src/helpers/mongoose-connection.ts"), exports);
|
|
@@ -206,13 +270,14 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
206
270
|
o[k2] = m[k];
|
|
207
271
|
}));
|
|
208
272
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
209
|
-
for (var p in m) if (p !== "default" && !
|
|
273
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
210
274
|
};
|
|
211
275
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
212
276
|
__exportStar(__webpack_require__(/*! ./interfaces */ "./src/interfaces/index.ts"), exports);
|
|
213
277
|
__exportStar(__webpack_require__(/*! ./helpers */ "./src/helpers/index.ts"), exports);
|
|
214
278
|
__exportStar(__webpack_require__(/*! ./services */ "./src/services/index.ts"), exports);
|
|
215
279
|
__exportStar(__webpack_require__(/*! ./store */ "./src/store/index.ts"), exports);
|
|
280
|
+
__exportStar(__webpack_require__(/*! ./dataloaders */ "./src/dataloaders/index.ts"), exports);
|
|
216
281
|
|
|
217
282
|
|
|
218
283
|
/***/ }),
|
|
@@ -243,6 +308,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
243
308
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
244
309
|
|
|
245
310
|
|
|
311
|
+
/***/ }),
|
|
312
|
+
|
|
313
|
+
/***/ "./src/interfaces/dataloaders.ts":
|
|
314
|
+
/*!***************************************!*\
|
|
315
|
+
!*** ./src/interfaces/dataloaders.ts ***!
|
|
316
|
+
\***************************************/
|
|
317
|
+
/*! no static exports found */
|
|
318
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
319
|
+
|
|
320
|
+
"use strict";
|
|
321
|
+
|
|
322
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
323
|
+
|
|
324
|
+
|
|
246
325
|
/***/ }),
|
|
247
326
|
|
|
248
327
|
/***/ "./src/interfaces/get-all-args.ts":
|
|
@@ -282,13 +361,14 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
282
361
|
o[k2] = m[k];
|
|
283
362
|
}));
|
|
284
363
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
285
|
-
for (var p in m) if (p !== "default" && !
|
|
364
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
286
365
|
};
|
|
287
366
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
288
367
|
__exportStar(__webpack_require__(/*! ./mongoose-settings */ "./src/interfaces/mongoose-settings.ts"), exports);
|
|
289
368
|
__exportStar(__webpack_require__(/*! ./get-all-args */ "./src/interfaces/get-all-args.ts"), exports);
|
|
290
369
|
__exportStar(__webpack_require__(/*! ./base-repository */ "./src/interfaces/base-repository.ts"), exports);
|
|
291
370
|
__exportStar(__webpack_require__(/*! ./base-service */ "./src/interfaces/base-service.ts"), exports);
|
|
371
|
+
__exportStar(__webpack_require__(/*! ./dataloaders */ "./src/interfaces/dataloaders.ts"), exports);
|
|
292
372
|
|
|
293
373
|
|
|
294
374
|
/***/ }),
|
|
@@ -412,7 +492,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
412
492
|
o[k2] = m[k];
|
|
413
493
|
}));
|
|
414
494
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
415
|
-
for (var p in m) if (p !== "default" && !
|
|
495
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
416
496
|
};
|
|
417
497
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
418
498
|
__exportStar(__webpack_require__(/*! ./base-service */ "./src/services/base-service.ts"), exports);
|
|
@@ -437,7 +517,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
437
517
|
o[k2] = m[k];
|
|
438
518
|
}));
|
|
439
519
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
440
|
-
for (var p in m) if (p !== "default" && !
|
|
520
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
441
521
|
};
|
|
442
522
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
443
523
|
__exportStar(__webpack_require__(/*! ./models */ "./src/store/models/index.ts"), exports);
|
|
@@ -471,12 +551,13 @@ exports.commonModeSchemaOptions = {
|
|
|
471
551
|
},
|
|
472
552
|
},
|
|
473
553
|
};
|
|
474
|
-
|
|
554
|
+
const addIdVirtualFields = (schema) => {
|
|
475
555
|
schema.set('toJSON', {
|
|
476
556
|
virtuals: true,
|
|
477
557
|
});
|
|
478
558
|
return schema;
|
|
479
559
|
};
|
|
560
|
+
exports.addIdVirtualFields = addIdVirtualFields;
|
|
480
561
|
|
|
481
562
|
|
|
482
563
|
/***/ }),
|
|
@@ -498,7 +579,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
498
579
|
o[k2] = m[k];
|
|
499
580
|
}));
|
|
500
581
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
501
|
-
for (var p in m) if (p !== "default" && !
|
|
582
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
502
583
|
};
|
|
503
584
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
504
585
|
__exportStar(__webpack_require__(/*! ./common-options */ "./src/store/models/common-options.ts"), exports);
|
|
@@ -705,12 +786,23 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
705
786
|
o[k2] = m[k];
|
|
706
787
|
}));
|
|
707
788
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
708
|
-
for (var p in m) if (p !== "default" && !
|
|
789
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
709
790
|
};
|
|
710
791
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
711
792
|
__exportStar(__webpack_require__(/*! ./base-repository */ "./src/store/repositories/base-repository.ts"), exports);
|
|
712
793
|
|
|
713
794
|
|
|
795
|
+
/***/ }),
|
|
796
|
+
|
|
797
|
+
/***/ "dataloader":
|
|
798
|
+
/*!*****************************!*\
|
|
799
|
+
!*** external "dataloader" ***!
|
|
800
|
+
\*****************************/
|
|
801
|
+
/*! no static exports found */
|
|
802
|
+
/***/ (function(module, exports) {
|
|
803
|
+
|
|
804
|
+
module.exports = require("dataloader");
|
|
805
|
+
|
|
714
806
|
/***/ }),
|
|
715
807
|
|
|
716
808
|
/***/ "inversify":
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./src/constants/default-options.ts","webpack:///./src/constants/index.ts","webpack:///./src/helpers/index.ts","webpack:///./src/helpers/mongoose-connection.ts","webpack:///./src/index.ts","webpack:///./src/interfaces/get-all-args.ts","webpack:///./src/interfaces/index.ts","webpack:///./src/services/base-service.ts","webpack:///./src/services/index.ts","webpack:///./src/store/index.ts","webpack:///./src/store/models/common-options.ts","webpack:///./src/store/models/index.ts","webpack:///./src/store/repositories/base-repository.ts","webpack:///./src/store/repositories/index.ts","webpack:///external \"inversify\"","webpack:///external \"lodash\"","webpack:///external \"mongoose\""],"names":[],"mappings":";;QAAA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gHAAgH,mBAAmB,EAAE;QACrI;QACA;;QAEA;QACA;QACA;QACA,2BAA2B,0BAA0B,EAAE;QACvD,iCAAiC,eAAe;QAChD;QACA;QACA;;QAEA;QACA,sDAAsD,+DAA+D;;QAErH;QACA;;;QAGA;QACA;;;;;;;;;;;;;;;;AClFa,uBAAe,GAAG;IAC3B,EAAE,EAAE,KAAK;CACZ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;ACFF,0GAAkC;;;;;;;;;;;;;;;;;;;;;;;;;ACAlC,gHAAsC;;;;;;;;;;;;;;;;AC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CAqK1B;AArKY,wCAAc;;;;;;;;;;;;;;;;;;;;;;;;;ACT3B,mHAAkC;;;;;;;;;;;;ACAlC,sC;;;;;;;;;;;ACAA,mC;;;;;;;;;;;ACAA,qC","file":"index.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = \"./src/index.ts\");\n","export const DEFAULT_SORTING = {\n id: 'asc',\n};\n","export * from './default-options';\n","export * from './mongoose-connection';\n","import * as mongoose from 'mongoose';\n\nlet connectionOptions: mongoose.ConnectionOptions | undefined;\n// (mongoose as any).Promise = global.Promise;\n\nconst generateMongo: (monoUrl) => mongoose.Connection = (mongoUrl) => {\n\n // creates default connection\n mongoose.connect(mongoUrl, {\n }).then(() => {\n console.info('mogoose connect - success');\n // console.info(`uri - ${uri}`);\n // console.info(`connectionOptions - ${connectionOptions}`);\n }).catch((err: mongoose.Error) => {\n console.error('mogoose connect - error - ', err);\n // throw err;\n process.kill(process.pid);\n });\n // to access default connection\n const mongooseConnection: mongoose.Connection = mongoose.connection;\n\n return mongooseConnection;\n};\n\n\n\nexport { generateMongo };\n","export * from './interfaces';\nexport * from './helpers';\nexport * from './services';\nexport * from './store';\n","import { FilterQuery } from 'mongoose';\n\nexport type ISort = {\n key: string;\n value: ISortEnum;\n};\n\nexport enum ISortEnum {\n ASC = 'ASC',\n DESC = 'DESC'\n}\n\nexport interface GetAllArgs<T> {\n criteria?: FilterQuery<T>;\n sort?: ISort;\n skip?: number;\n limit?: number;\n selectedFields?: string;\n}\n","export * from './mongoose-settings';\nexport * from './get-all-args';\nexport * from './base-repository';\nexport * from './base-service';\n","import { Document, FilterQuery } from 'mongoose';\nimport { injectable } from 'inversify';\nimport { GetAllArgs, IBaseRepository, IBaseService } from '../interfaces';\n\n@injectable()\nexport class BaseService<T, C = Omit<T, 'id'>, U = C> implements IBaseService<T, C, U> {\n constructor(protected repository: IBaseRepository<T>) {\n this.repository = repository;\n }\n\n async getAllWithCount(options: GetAllArgs<Document<T>>): Promise<{ data: T[]; totalCount: number }> {\n const totalCount = await this.count(options.criteria);\n const data = await this.getAll(options);\n return {\n totalCount,\n data,\n };\n }\n\n count(conditions?: FilterQuery<Document<T>>): Promise<number> {\n return this.repository.count(conditions);\n }\n\n get(id: string): Promise<T> {\n return this.repository.get({ id });\n }\n\n getName(name: string): Promise<T> {\n return this.repository.get({ name });\n }\n\n getAll(options: GetAllArgs<Document<T>>): Promise<T[]> {\n return this.repository.getAll(options);\n }\n\n getByIds(ids: string[]): Promise<T[]> {\n return this.repository.bulkGet(ids);\n }\n\n create(data: C): Promise<T> {\n return this.repository.create<C>(data);\n }\n\n bulkCreate(data: C[]): Promise<T[]> {\n return this.repository.bulkCreate<C>(data);\n }\n\n async update(id: string, data: Partial<U>, overwrite = false): Promise<T> {\n return this.repository.update<U>({ id }, data, { overwrite });\n }\n\n insert(data: (C | U) & { id?: string }, overwrite = true): Promise<T> {\n const { id, ...rest } = data;\n if (id) {\n const existing = this.repository.get({ id });\n if (existing) {\n return this.update(id, rest as U, overwrite);\n }\n }\n return this.create(rest as C);\n }\n\n delete(id: string): Promise<boolean> {\n return this.repository.delete({ id });\n }\n}\n","export * from './base-service';\n","export * from './models';\nexport * from './repositories';\n","import { Schema } from 'mongoose';\n\nexport const commonModeSchemaOptions = {\n timestamps: true,\n toJSON: {\n virtuals: true,\n },\n toObject: {\n virtuals: true,\n getters: true,\n transform(doc, ret) {\n delete ret.__v;\n delete ret._id;\n },\n },\n};\n\nexport const addIdVirtualFields = (schema: Schema) => {\n schema.set('toJSON', {\n virtuals: true,\n });\n return schema;\n};\n","export * from './common-options';\n","import { isObject } from 'lodash';\nimport { logger as Logger } from '@cdm-logger/server';\nimport { Connection, Document, FilterQuery, Model, UpdateQuery } from 'mongoose';\nimport { injectable, unmanaged } from 'inversify';\nimport { GetAllArgs, IBaseRepository, IMongoOptions } from '../../interfaces';\nimport { DEFAULT_SORTING } from '../../constants';\n\nconst DEFAULT_PAGINATION_LIMIT = 10;\n@injectable()\nexport class BaseRepository<T, D = Document<T>> implements IBaseRepository<T, D> {\n private options: IMongoOptions;\n\n protected logger: typeof Logger;\n\n model: Model<D>;\n\n constructor(\n @unmanaged()\n private modelFunc: (db: Connection) => Model<D>,\n @unmanaged()\n db: Connection,\n @unmanaged()\n logger: typeof Logger,\n @unmanaged()\n options?: IMongoOptions,\n ) {\n this.model = modelFunc(db);\n this.options = options;\n this.logger = logger.child({ className: BaseRepository.name });\n }\n\n public async getAll(options: GetAllArgs<D>): Promise<T[]> {\n try {\n const { criteria, selectedFields, sort, limit, skip } = options;\n // map id to mongoose _id\n const { id, ...rest } = criteria || { id: undefined };\n const response = await this.model\n .find({ ...rest, ...(id ? { _id: id } : {}) }, selectedFields)\n .limit(limit || DEFAULT_PAGINATION_LIMIT)\n .skip(skip || 0)\n .sort(isObject(sort) ? { [sort?.key]: sort.value } : DEFAULT_SORTING)\n .exec();\n return response.map((i) => i?.toObject()) as T[];\n } catch (e) {\n this.logger.error(`Unable to retrieve Model with criteria ${JSON.stringify(options)}`);\n throw e;\n }\n }\n\n // eslint-disable-next-line class-methods-use-this\n private mapConditions(conditions: FilterQuery<D>): FilterQuery<D> {\n const { id: _id, ...remaining } = conditions;\n return {\n ...(_id ? { _id } : {}),\n ...remaining,\n };\n }\n\n public async count(conditions?: FilterQuery<D>): Promise<number> {\n return this.model.count(conditions).exec();\n }\n\n public async get(conditions?: FilterQuery<D>, selectedFields?: string): Promise<T> {\n try {\n const response = await this.model.findOne(this.mapConditions(conditions), selectedFields).exec();\n return response?.toObject() as T;\n } catch (e) {\n this.logger.error(`Unable to retrieve Model with criteria ${JSON.stringify(conditions)}`);\n throw e;\n }\n }\n\n public async bulkGet(ids: string[]): Promise<T[]> {\n try {\n const results = await this.model.find().setOptions({ batchSize: 100 }).where('_id').in(ids).exec();\n return results.map((i) => i.toObject()) as T[];\n } catch (e) {\n this.logger.error(`Unable to retrieve Model with criteria ${JSON.stringify(ids)}`);\n throw e;\n }\n }\n\n public async find(conditions: Partial<FilterQuery<D>>, selectedFields?: string): Promise<T> {\n try {\n const response = await this.model.findOne(conditions, selectedFields).exec();\n return response?.toObject() as T;\n } catch (e) {\n this.logger.error(`Unable to retrieve Model with criteria ${JSON.stringify(conditions)}`);\n throw e;\n }\n }\n\n public async create<I>(data: I): Promise<T> {\n try {\n const response = await this.model.create(data);\n return response.toObject() as T;\n } catch (e) {\n this.logger.error(`Unable to create Model with data ${JSON.stringify(data)} due to ${e?.message}`);\n throw e;\n }\n }\n\n public async bulkCreate<I>(data: I[]): Promise<T[]> {\n try {\n const response = await this.model.insertMany(data, {\n lean: true,\n ordered: true,\n });\n return response as unknown as T[];\n } catch (e) {\n this.logger.error(`Unable to bulk create due to error`, e.message);\n }\n }\n\n public async upsert<I>(conditions: FilterQuery<D>, update: I, options?: Record<string, unknown>): Promise<T> {\n return this.update<I>(conditions, update, {\n upsert: true,\n ...options,\n });\n }\n\n public async update<I>(\n criteria: FilterQuery<D>,\n update: UpdateQuery<D>,\n options: Record<string, unknown>,\n ): Promise<T> {\n try {\n const { id, ...rest } = criteria;\n const processedCriteria = id ? { _id: id, ...rest } : criteria;\n const mergedOptions = {\n new: true,\n useFindAndModify: false,\n ...options,\n };\n if (id) {\n return (await this.model\n .findByIdAndUpdate(id, update as unknown as never, mergedOptions)\n .exec()) as unknown as Promise<T>;\n }\n return (await this.model\n .findOneAndUpdate(processedCriteria, update as unknown as never, mergedOptions)\n .exec()) as unknown as Promise<T>;\n } catch (e) {\n this.logger.error(\n `Unable to Update with criteria ${JSON.stringify(criteria)} and data ${JSON.stringify(update)}`,\n );\n throw e;\n }\n }\n\n public async delete(criteria: FilterQuery<D>): Promise<boolean> {\n try {\n let deleted;\n if (criteria?.id) {\n deleted = await this.model.findByIdAndDelete(criteria.id);\n } else {\n deleted = await this.model.findOneAndDelete(this.mapConditions(criteria));\n }\n return !!deleted;\n } catch (e) {\n this.logger.error(`Unable to delete the model with criteria`, criteria);\n throw e;\n }\n }\n\n public async bulkDelete(conditions: FilterQuery<D>): Promise<number> {\n try {\n const deleted = await this.model.deleteMany(conditions);\n return deleted?.deletedCount || 0;\n } catch (e) {\n this.logger.error(`Unable to delete the model with criteria`, conditions);\n throw e;\n }\n }\n}\n","export * from './base-repository';\n","module.exports = require(\"inversify\");","module.exports = require(\"lodash\");","module.exports = require(\"mongoose\");"],"sourceRoot":""}
|
|
1
|
+
{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./src/constants/default-options.ts","webpack:///./src/constants/index.ts","webpack:///./src/dataloaders/bulk-dataloader.ts","webpack:///./src/dataloaders/index.ts","webpack:///./src/helpers/index.ts","webpack:///./src/helpers/mongoose-connection.ts","webpack:///./src/index.ts","webpack:///./src/interfaces/get-all-args.ts","webpack:///./src/interfaces/index.ts","webpack:///./src/services/base-service.ts","webpack:///./src/services/index.ts","webpack:///./src/store/index.ts","webpack:///./src/store/models/common-options.ts","webpack:///./src/store/models/index.ts","webpack:///./src/store/repositories/base-repository.ts","webpack:///./src/store/repositories/index.ts","webpack:///external \"dataloader\"","webpack:///external \"inversify\"","webpack:///external \"lodash\"","webpack:///external \"mongoose\""],"names":[],"mappings":";;QAAA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,k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,uC;;;;;;;;;;;ACAA,sC;;;;;;;;;;;ACAA,mC;;;;;;;;;;;ACAA,qC","file":"index.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = \"./src/index.ts\");\n","export const DEFAULT_SORTING = {\n id: 'asc',\n};\n","export * from './default-options';\n","import * as DataLoader from 'dataloader';\nimport { injectable, unmanaged } from 'inversify';\nimport { IBaseService } from '../interfaces';\n\n@injectable()\nexport class BulkDataLoader<T extends { id: string }> extends DataLoader<string, T> {\n constructor(\n @unmanaged()\n service: IBaseService<T>,\n ) {\n super(async (ids: string[]) => {\n const data = await service.getByIds(ids);\n return ids.map((id) => data.find((record) => record.id === id));\n });\n }\n}\n","export * from './bulk-dataloader';\n","export * from './mongoose-connection';\n","import * as mongoose from 'mongoose';\n\nlet connectionOptions: mongoose.ConnectionOptions | undefined;\n// (mongoose as any).Promise = global.Promise;\n\nconst generateMongo: (monoUrl) => mongoose.Connection = (mongoUrl) => {\n\n // creates default connection\n mongoose.connect(mongoUrl, {\n }).then(() => {\n console.info('mogoose connect - success');\n // console.info(`uri - ${uri}`);\n // console.info(`connectionOptions - ${connectionOptions}`);\n }).catch((err: mongoose.Error) => {\n console.error('mogoose connect - error - ', err);\n // throw err;\n process.kill(process.pid);\n });\n // to access default connection\n const mongooseConnection: mongoose.Connection = mongoose.connection;\n\n return mongooseConnection;\n};\n\n\n\nexport { generateMongo };\n","export * from './interfaces';\nexport * from './helpers';\nexport * from './services';\nexport * from './store';\nexport * from './dataloaders';\n","import { FilterQuery } from 'mongoose';\n\nexport type ISort = {\n key: string;\n value: ISortEnum;\n};\n\nexport enum ISortEnum {\n ASC = 'ASC',\n DESC = 'DESC'\n}\n\nexport interface GetAllArgs<T> {\n criteria?: FilterQuery<T>;\n sort?: ISort;\n skip?: number;\n limit?: number;\n selectedFields?: string;\n}\n","export * from './mongoose-settings';\nexport * from './get-all-args';\nexport * from './base-repository';\nexport * from './base-service';\nexport * from './dataloaders';\n","import { Document, FilterQuery } from 'mongoose';\nimport { injectable } from 'inversify';\nimport { GetAllArgs, IBaseRepository, IBaseService } from '../interfaces';\n\n@injectable()\nexport class BaseService<T, C = Omit<T, 'id'>, U = C> implements IBaseService<T, C, U> {\n constructor(protected repository: IBaseRepository<T>) {\n this.repository = repository;\n }\n\n async getAllWithCount(options: GetAllArgs<Document<T>>): Promise<{ data: T[]; totalCount: number }> {\n const totalCount = await this.count(options.criteria);\n const data = await this.getAll(options);\n return {\n totalCount,\n data,\n };\n }\n\n count(conditions?: FilterQuery<Document<T>>): Promise<number> {\n return this.repository.count(conditions);\n }\n\n get(id: string): Promise<T> {\n return this.repository.get({ id });\n }\n\n getName(name: string): Promise<T> {\n return this.repository.get({ name });\n }\n\n getAll(options: GetAllArgs<Document<T>>): Promise<T[]> {\n return this.repository.getAll(options);\n }\n\n getByIds(ids: string[]): Promise<T[]> {\n return this.repository.bulkGet(ids);\n }\n\n create(data: C): Promise<T> {\n return this.repository.create<C>(data);\n }\n\n bulkCreate(data: C[]): Promise<T[]> {\n return this.repository.bulkCreate<C>(data);\n }\n\n async update(id: string, data: Partial<U>, overwrite = false): Promise<T> {\n return this.repository.update<U>({ id }, data, { overwrite });\n }\n\n insert(data: (C | U) & { id?: string }, overwrite = true): Promise<T> {\n const { id, ...rest } = data;\n if (id) {\n const existing = this.repository.get({ id });\n if (existing) {\n return this.update(id, rest as U, overwrite);\n }\n }\n return this.create(rest as C);\n }\n\n delete(id: string): Promise<boolean> {\n return this.repository.delete({ id });\n }\n}\n","export * from './base-service';\n","export * from './models';\nexport * from './repositories';\n","import { Schema } from 'mongoose';\n\nexport const commonModeSchemaOptions = {\n timestamps: true,\n toJSON: {\n virtuals: true,\n },\n toObject: {\n virtuals: true,\n getters: true,\n transform(doc, ret) {\n delete ret.__v;\n delete ret._id;\n },\n },\n};\n\nexport const addIdVirtualFields = (schema: Schema) => {\n schema.set('toJSON', {\n virtuals: true,\n });\n return schema;\n};\n","export * from './common-options';\n","import { isObject } from 'lodash';\nimport { logger as Logger } from '@cdm-logger/server';\nimport { Connection, Document, FilterQuery, Model, UpdateQuery } from 'mongoose';\nimport { injectable, unmanaged } from 'inversify';\nimport { GetAllArgs, IBaseRepository, IMongoOptions } from '../../interfaces';\nimport { DEFAULT_SORTING } from '../../constants';\n\nconst DEFAULT_PAGINATION_LIMIT = 10;\n@injectable()\nexport class BaseRepository<T, D = Document<T>> implements IBaseRepository<T, D> {\n private options: IMongoOptions;\n\n protected logger: typeof Logger;\n\n model: Model<D>;\n\n constructor(\n @unmanaged()\n private modelFunc: (db: Connection) => Model<D>,\n @unmanaged()\n db: Connection,\n @unmanaged()\n logger: typeof Logger,\n @unmanaged()\n options?: IMongoOptions,\n ) {\n this.model = modelFunc(db);\n this.options = options;\n this.logger = logger.child({ className: BaseRepository.name });\n }\n\n public async getAll(options: GetAllArgs<D>): Promise<T[]> {\n try {\n const { criteria, selectedFields, sort, limit, skip } = options;\n // map id to mongoose _id\n const { id, ...rest } = criteria || { id: undefined };\n const response = await this.model\n .find({ ...rest, ...(id ? { _id: id } : {}) }, selectedFields)\n .limit(limit || DEFAULT_PAGINATION_LIMIT)\n .skip(skip || 0)\n .sort(isObject(sort) ? { [sort?.key]: sort.value } : DEFAULT_SORTING)\n .exec();\n return response.map((i) => i?.toObject()) as T[];\n } catch (e) {\n this.logger.error(`Unable to retrieve Model with criteria ${JSON.stringify(options)}`);\n throw e;\n }\n }\n\n // eslint-disable-next-line class-methods-use-this\n private mapConditions(conditions: FilterQuery<D>): FilterQuery<D> {\n const { id: _id, ...remaining } = conditions;\n return {\n ...(_id ? { _id } : {}),\n ...remaining,\n };\n }\n\n public async count(conditions?: FilterQuery<D>): Promise<number> {\n return this.model.count(conditions).exec();\n }\n\n public async get(conditions?: FilterQuery<D>, selectedFields?: string): Promise<T> {\n try {\n const response = await this.model.findOne(this.mapConditions(conditions), selectedFields).exec();\n return response?.toObject() as T;\n } catch (e) {\n this.logger.error(`Unable to retrieve Model with criteria ${JSON.stringify(conditions)}`);\n throw e;\n }\n }\n\n public async bulkGet(ids: string[]): Promise<T[]> {\n try {\n const results = await this.model.find().setOptions({ batchSize: 100 }).where('_id').in(ids).exec();\n return results.map((i) => i.toObject()) as T[];\n } catch (e) {\n this.logger.error(`Unable to retrieve Model with criteria ${JSON.stringify(ids)}`);\n throw e;\n }\n }\n\n public async find(conditions: Partial<FilterQuery<D>>, selectedFields?: string): Promise<T> {\n try {\n const response = await this.model.findOne(conditions, selectedFields).exec();\n return response?.toObject() as T;\n } catch (e) {\n this.logger.error(`Unable to retrieve Model with criteria ${JSON.stringify(conditions)}`);\n throw e;\n }\n }\n\n public async create<I>(data: I): Promise<T> {\n try {\n const response = await this.model.create(data);\n return response.toObject() as T;\n } catch (e) {\n this.logger.error(`Unable to create Model with data ${JSON.stringify(data)} due to ${e?.message}`);\n throw e;\n }\n }\n\n public async bulkCreate<I>(data: I[]): Promise<T[]> {\n try {\n const response = await this.model.insertMany(data, {\n lean: true,\n ordered: true,\n });\n return response as unknown as T[];\n } catch (e) {\n this.logger.error(`Unable to bulk create due to error`, e.message);\n }\n }\n\n public async upsert<I>(conditions: FilterQuery<D>, update: I, options?: Record<string, unknown>): Promise<T> {\n return this.update<I>(conditions, update, {\n upsert: true,\n ...options,\n });\n }\n\n public async update<I>(\n criteria: FilterQuery<D>,\n update: UpdateQuery<D>,\n options: Record<string, unknown>,\n ): Promise<T> {\n try {\n const { id, ...rest } = criteria;\n const processedCriteria = id ? { _id: id, ...rest } : criteria;\n const mergedOptions = {\n new: true,\n useFindAndModify: false,\n ...options,\n };\n if (id) {\n return (await this.model\n .findByIdAndUpdate(id, update as unknown as never, mergedOptions)\n .exec()) as unknown as Promise<T>;\n }\n return (await this.model\n .findOneAndUpdate(processedCriteria, update as unknown as never, mergedOptions)\n .exec()) as unknown as Promise<T>;\n } catch (e) {\n this.logger.error(\n `Unable to Update with criteria ${JSON.stringify(criteria)} and data ${JSON.stringify(update)}`,\n );\n throw e;\n }\n }\n\n public async delete(criteria: FilterQuery<D>): Promise<boolean> {\n try {\n let deleted;\n if (criteria?.id) {\n deleted = await this.model.findByIdAndDelete(criteria.id);\n } else {\n deleted = await this.model.findOneAndDelete(this.mapConditions(criteria));\n }\n return !!deleted;\n } catch (e) {\n this.logger.error(`Unable to delete the model with criteria`, criteria);\n throw e;\n }\n }\n\n public async bulkDelete(conditions: FilterQuery<D>): Promise<number> {\n try {\n const deleted = await this.model.deleteMany(conditions);\n return deleted?.deletedCount || 0;\n } catch (e) {\n this.logger.error(`Unable to delete the model with criteria`, conditions);\n throw e;\n }\n }\n}\n","export * from './base-repository';\n","module.exports = require(\"dataloader\");","module.exports = require(\"inversify\");","module.exports = require(\"lodash\");","module.exports = require(\"mongoose\");"],"sourceRoot":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@common-stack/store-mongo",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.21",
|
|
4
4
|
"description": "Sample core for higher packages to depend on",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "CDMBase LLC",
|
|
@@ -19,9 +19,10 @@
|
|
|
19
19
|
"watch": "npm run build:lib:watch"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@common-stack/core": "^0.1.
|
|
22
|
+
"@common-stack/core": "^0.1.21"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
|
+
"dataloader": ">=2.0.0",
|
|
25
26
|
"mongoose": ">=5.13.5"
|
|
26
27
|
},
|
|
27
28
|
"publishConfig": {
|
|
@@ -30,5 +31,5 @@
|
|
|
30
31
|
"typescript": {
|
|
31
32
|
"definition": "lib/index.d.ts"
|
|
32
33
|
},
|
|
33
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "c3e769cce851a170b380a58a894ed6f312fed8a0"
|
|
34
35
|
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
# Change Log
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file.
|
|
4
|
-
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
-
|
|
6
|
-
## [0.1.12](https://github.com/cdmbase/common-stack/compare/v0.1.11...v0.1.12) (2021-12-10)
|
|
7
|
-
|
|
8
|
-
**Note:** Version bump only for package @common-stack/store-mongo
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
## [0.1.11](https://github.com/cdmbase/common-stack/compare/v0.1.10...v0.1.11) (2021-11-07)
|
|
15
|
-
|
|
16
|
-
**Note:** Version bump only for package @common-stack/store-mongo
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
## [0.1.9](https://github.com/cdmbase/common-stack/compare/v0.1.8...v0.1.9) (2021-10-07)
|
|
23
|
-
|
|
24
|
-
**Note:** Version bump only for package @common-stack/store-mongo
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
## [0.1.7](https://github.com/cdmbase/common-stack/compare/v0.1.6...v0.1.7) (2021-08-11)
|
|
31
|
-
|
|
32
|
-
**Note:** Version bump only for package @common-stack/store-mongo
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
## [0.1.6](https://github.com/cdmbase/common-stack/compare/v0.1.5...v0.1.6) (2021-08-11)
|
|
39
|
-
|
|
40
|
-
**Note:** Version bump only for package @common-stack/store-mongo
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
## [0.1.5](https://github.com/cdmbase/common-stack/compare/v0.1.4...v0.1.5) (2021-08-11)
|
|
47
|
-
|
|
48
|
-
**Note:** Version bump only for package @common-stack/store-mongo
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
## [0.1.4](https://github.com/cdmbase/common-stack/compare/v0.1.3...v0.1.4) (2021-08-11)
|
|
55
|
-
|
|
56
|
-
**Note:** Version bump only for package @common-stack/store-mongo
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
## [0.1.3](https://github.com/cdmbase/common-stack/compare/v0.1.2...v0.1.3) (2021-08-11)
|
|
63
|
-
|
|
64
|
-
**Note:** Version bump only for package @common-stack/store-mongo
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
## [0.1.1](https://github.com/cdmbase/common-stack/compare/v0.0.264...v0.1.1) (2021-08-05)
|
|
71
|
-
|
|
72
|
-
**Note:** Version bump only for package @common-stack/store-mongo
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
## [0.0.264](https://github.com/cdmbase/common-stack/compare/v0.0.263...v0.0.264) (2021-07-04)
|
|
79
|
-
|
|
80
|
-
**Note:** Version bump only for package @common-stack/store-mongo
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
## [0.0.263](https://github.com/cdmbase/common-stack/compare/v0.0.262...v0.0.263) (2021-07-03)
|
|
87
|
-
|
|
88
|
-
**Note:** Version bump only for package @common-stack/store-mongo
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
## [0.0.262](https://github.com/cdmbase/common-stack/compare/v0.0.261...v0.0.262) (2021-06-23)
|
|
95
|
-
|
|
96
|
-
**Note:** Version bump only for package @common-stack/store-mongo
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
## [0.0.261](https://github.com/cdmbase/common-stack/compare/v0.0.260...v0.0.261) (2021-06-01)
|
|
103
|
-
|
|
104
|
-
**Note:** Version bump only for package @common-stack/store-mongo
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
## [0.0.260](https://github.com/cdmbase/common-stack/compare/v0.0.259...v0.0.260) (2021-05-28)
|
|
111
|
-
|
|
112
|
-
**Note:** Version bump only for package @common-stack/store-mongo
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
## [0.0.259](https://github.com/cdmbase/common-stack/compare/v0.0.258...v0.0.259) (2021-05-28)
|
|
119
|
-
|
|
120
|
-
**Note:** Version bump only for package @common-stack/store-mongo
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
## [0.0.258](https://github.com/cdmbase/common-stack/compare/v0.0.257...v0.0.258) (2021-05-14)
|
|
127
|
-
|
|
128
|
-
**Note:** Version bump only for package @common-stack/store-mongo
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
## [0.0.257](https://github.com/cdmbase/common-stack/compare/v0.0.256...v0.0.257) (2021-05-05)
|
|
135
|
-
|
|
136
|
-
**Note:** Version bump only for package @common-stack/store-mongo
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
## [0.0.256](https://github.com/cdmbase/common-stack/compare/v0.0.255...v0.0.256) (2021-05-05)
|
|
143
|
-
|
|
144
|
-
**Note:** Version bump only for package @common-stack/store-mongo
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
## [0.0.255](https://github.com/cdmbase/common-stack/compare/v0.0.254...v0.0.255) (2021-04-03)
|
|
151
|
-
|
|
152
|
-
**Note:** Version bump only for package @common-stack/store-mongo
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
## [0.0.254](https://github.com/cdmbase/common-stack/compare/v0.0.253...v0.0.254) (2021-03-31)
|
|
159
|
-
|
|
160
|
-
**Note:** Version bump only for package @common-stack/store-mongo
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
## [0.0.253](https://github.com/cdmbase/common-stack/compare/v0.0.252...v0.0.253) (2021-03-31)
|
|
167
|
-
|
|
168
|
-
**Note:** Version bump only for package @common-stack/store-mongo
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
## [0.0.252](https://github.com/cdmbase/common-stack/compare/v0.0.251...v0.0.252) (2021-03-29)
|
|
175
|
-
|
|
176
|
-
**Note:** Version bump only for package @common-stack/store-mongo
|