Comparing version 1.1.1 to 1.2.0
@@ -14,3 +14,3 @@ "use strict"; | ||
const fns = Reflect.getMetadata(`${types_1.PRE_KEY}_${event}`, target) || []; | ||
fns.push(target[name].bind(target)); | ||
fns.push(target[name]); | ||
Reflect.defineMetadata(`${types_1.PRE_KEY}_${event}`, fns, target); | ||
@@ -25,3 +25,3 @@ } | ||
const fns = Reflect.getMetadata(`${types_1.POST_KEY}_${event}`, target) || []; | ||
fns.push(target[name].bind(target)); | ||
fns.push(target[name]); | ||
Reflect.defineMetadata(`${types_1.POST_KEY}_${event}`, fns, target); | ||
@@ -32,2 +32,2 @@ } | ||
exports.After = After; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGVjb3JhdG9ycy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9kZWNvcmF0b3JzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQUEsbUNBQXVFO0FBRXZFLG9CQUEyQixLQUFzQjtJQUMvQyxNQUFNLENBQUMsVUFBUyxNQUFXO1FBQ3pCLE9BQU8sQ0FBQyxjQUFjLENBQUMsZ0JBQVEsRUFBRSxLQUFLLENBQUMsSUFBSSxFQUFFLE1BQU0sQ0FBQyxTQUFTLENBQUMsQ0FBQztJQUNqRSxDQUFDLENBQUM7QUFDSixDQUFDO0FBSkQsZ0NBSUM7QUFFRCxnQkFBdUIsR0FBRyxNQUFnQjtJQUN4QyxNQUFNLENBQUMsVUFBUyxNQUFXLEVBQUUsSUFBWSxFQUFFLFVBQXdDO1FBQ2pGLEdBQUcsQ0FBQSxDQUFDLE1BQU0sS0FBSyxJQUFJLE1BQU0sQ0FBQyxDQUFDLENBQUM7WUFDMUIsTUFBTSxHQUFHLEdBQUcsT0FBTyxDQUFDLFdBQVcsQ0FBQyxHQUFHLGVBQU8sSUFBSSxLQUFLLEVBQUUsRUFBRSxNQUFNLENBQUMsSUFBSSxFQUFFL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jcmlwdG9yPGFueT4pIHtcbiAgICBmb3IoY29uc3QgZXZlbnQgb2YgZXZlbnRzKSB7XG4gICAgICBjb25zdCBmbnMgPSBSZWZsZWN0LmdldE1ldGFkYXRhKGAke1BSRV9LRVl9XyR7ZXZlbnR9YCwgdGFyZ2V0KSB8fCBbXTtcbiAgICAgIGZucy5wdXNoKHRhcmdldFtuYW1lXSk7XG4gICAgICBSZWZsZWN0LmRlZmluZU1ldGFkYXRhKGAke1BSRV9LRVl9XyR7ZXZlbnR9YCwgZm5zLCB0YXJnZXQpO1xuICAgIH1cbiAgfTtcbn1cblxuZXhwb3J0IGZ1bmN0aW9uIEFmdGVyKC4uLmV2ZW50czogc3RyaW5nW10pIHtcbiAgcmV0dXJuIGZ1bmN0aW9uKHRhcmdldDogYW55LCBuYW1lOiBzdHJpbmcsIGRlc2NyaXB0b3I6IFR5cGVkUHJvcGVydHlEZXNjcmlwdG9yPGFueT4pIHtcbiAgICBmb3IoY29uc3QgZXZlbnQgb2YgZXZlbnRzKSB7XG4gICAgICBjb25zdCBmbnMgPSBSZWZsZWN0LmdldE1ldGFkYXRhKGAke1BPU1RfS0VZfV8ke2V2ZW50fWAsIHRhcmdldCkgfHwgW107XG4gICAgICBmbnMucHVzaCh0YXJnZXRbbmFtZV0pO1xuICAgICAgUmVmbGVjdC5kZWZpbmVNZXRhZGF0YShgJHtQT1NUX0tFWX1fJHtldmVudH1gLCBmbnMsIHRhcmdldCk7XG4gICAgfVxuICB9O1xufVxuIl19 |
@@ -11,4 +11,4 @@ import 'reflect-metadata'; | ||
constructor(db: Database); | ||
toggleId(document: any, replace: any): any; | ||
invokeEvents(type: any, fns: any, document: any): any; | ||
toggleId(document: any, replace: any): T; | ||
invokeEvents(type: any, fns: any, document: any): Promise<T>; | ||
findById(id: string): Promise<T>; | ||
@@ -15,0 +15,0 @@ findOne(conditions: any): Promise<T>; |
@@ -53,9 +53,14 @@ "use strict"; | ||
invokeEvents(type, fns, document) { | ||
for (const fn of fns) { | ||
const events = Reflect.getMetadata(`${type}_${fn}`, this) || []; | ||
for (const event of events) { | ||
document = event(document); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
for (const fn of fns) { | ||
const events = Reflect.getMetadata(`${type}_${fn}`, this) || []; | ||
for (const event of events) { | ||
document = event.bind(this)(document); | ||
if (typeof document.then === 'function') { | ||
document = yield document; | ||
} | ||
} | ||
} | ||
} | ||
return document; | ||
return document; | ||
}); | ||
} | ||
@@ -73,3 +78,3 @@ findById(id) { | ||
document = this.toggleId(document, false); | ||
document = this.invokeEvents(types_1.POST_KEY, ['find', 'findOne'], document); | ||
document = yield this.invokeEvents(types_1.POST_KEY, ['find', 'findOne'], document); | ||
return document; | ||
@@ -97,3 +102,4 @@ } | ||
document = this.toggleId(document, false); | ||
results.push(this.invokeEvents(types_1.POST_KEY, ['find', 'findMany'], document)); | ||
document = yield this.invokeEvents(types_1.POST_KEY, ['find', 'findMany'], document); | ||
results.push(document); | ||
} | ||
@@ -106,7 +112,7 @@ return results; | ||
const collection = yield this.collection; | ||
document = this.invokeEvents(types_1.PRE_KEY, ['save', 'create'], document); | ||
document = yield this.invokeEvents(types_1.PRE_KEY, ['save', 'create'], document); | ||
const res = yield collection.insertOne(document); | ||
let newDocument = res.ops[0]; | ||
newDocument = this.toggleId(newDocument, false); | ||
newDocument = this.invokeEvents(types_1.POST_KEY, ['save', 'create'], newDocument); | ||
newDocument = yield this.invokeEvents(types_1.POST_KEY, ['save', 'create'], newDocument); | ||
return newDocument; | ||
@@ -122,3 +128,3 @@ }); | ||
delete document._id; | ||
const updates = this.invokeEvents(types_1.PRE_KEY, ['save'], document); | ||
const updates = yield this.invokeEvents(types_1.PRE_KEY, ['save'], document); | ||
const res = yield collection.updateOne({ _id: id }, { $set: updates }, { upsert: true }); | ||
@@ -133,3 +139,3 @@ let newDocument = yield collection.findOne({ _id: id }); | ||
delete newDocument._id; | ||
newDocument = this.invokeEvents(types_1.POST_KEY, ['save'], newDocument); | ||
newDocument = yield this.invokeEvents(types_1.POST_KEY, ['save'], newDocument); | ||
return newDocument; | ||
@@ -150,3 +156,3 @@ }); | ||
const collection = yield this.collection; | ||
const updates = this.invokeEvents(types_1.PRE_KEY, ['update', 'updateOne'], req.updates); | ||
const updates = yield this.invokeEvents(types_1.PRE_KEY, ['update', 'updateOne'], req.updates); | ||
const res = yield collection | ||
@@ -156,3 +162,3 @@ .findOneAndUpdate(req.conditions, updates, { upsert: req.upsert, returnNewDocument: true }); | ||
document = this.toggleId(document, false); | ||
document = this.invokeEvents(types_1.POST_KEY, ['update', 'updateOne'], document); | ||
document = yield this.invokeEvents(types_1.POST_KEY, ['update', 'updateOne'], document); | ||
return document; | ||
@@ -186,2 +192,2 @@ }); | ||
exports.MongoRepository = MongoRepository; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVwb3NpdG9yeS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9yZXBvc2l0b3J5LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7QUFBQSw0QkFBMEI7QUFDMUIscUNBQXFGO0FBQ3JGLG1DQUFxRztBQUNyRyw2QkFBZ0M7QUFDaEMsK0NBQTBDO0FBRzFDLElBQWEsZUFBZSxHQUE1QjtJQWVFLFlBQW9CLEVBQVk7UUFBWixPQUFFLEdBQUYsRUFBRSxDQUFVO0lBQUksQ0FBQztJQWJyQyxJQUFJLElBQUk7UUFDTixNQUFNLENBQUMsT0FBTyxDQUFDLFdBQVcsQ0FBQyxnQkFBUSxFQUFFLElBQUksQ0FBQyxDQUFDO0lBQzdDLENBQUM7SUFFRCxJQUFJLFVBQVU7UUFDWixNQUFNLENBQUMsSUFBSSxDQUFDLEVBQUUsQ0FBQyxVQUFVO2FBQ3RCLElBQUksQ0FBQyxFQUFFLElBQUksRUFBRSxDQUFDLFVBQVUsQ0FBQyxJQUFJLENBQ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VjdGlvbiA9IGF3YWl0IHRoaXMuY29sbGVjdGlvbjtcbiAgICByZXR1cm4gY29sbGVjdGlvbi5kZWxldGVNYW55KGNvbmRpdGlvbnMpO1xuICB9XG5cbn1cbiJdfQ== |
{ | ||
"name": "mongtype", | ||
"version": "1.1.1", | ||
"version": "1.2.0", | ||
"description": "Mongo Repository for Node written in TypeScript", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -13,3 +13,3 @@ import { NAME_KEY, PRE_KEY, POST_KEY, CollectionProps } from './types'; | ||
const fns = Reflect.getMetadata(`${PRE_KEY}_${event}`, target) || []; | ||
fns.push(target[name].bind(target)); | ||
fns.push(target[name]); | ||
Reflect.defineMetadata(`${PRE_KEY}_${event}`, fns, target); | ||
@@ -24,3 +24,3 @@ } | ||
const fns = Reflect.getMetadata(`${POST_KEY}_${event}`, target) || []; | ||
fns.push(target[name].bind(target)); | ||
fns.push(target[name]); | ||
Reflect.defineMetadata(`${POST_KEY}_${event}`, fns, target); | ||
@@ -27,0 +27,0 @@ } |
@@ -25,3 +25,3 @@ import 'reflect-metadata'; | ||
toggleId(document, replace): any { | ||
toggleId(document, replace): T { | ||
if(document.id || document._id) { | ||
@@ -39,7 +39,10 @@ if(replace) { | ||
invokeEvents(type, fns, document): any { | ||
async invokeEvents(type, fns, document): Promise<T> { | ||
for(const fn of fns) { | ||
const events = Reflect.getMetadata(`${type}_${fn}`, this) || []; | ||
for(const event of events) { | ||
document = event(document); | ||
document = event.bind(this)(document); | ||
if (typeof document.then === 'function') { | ||
document = await document; | ||
} | ||
} | ||
@@ -63,3 +66,3 @@ } | ||
document = this.toggleId(document, false); | ||
document = this.invokeEvents(POST_KEY, ['find', 'findOne'], document); | ||
document = await this.invokeEvents(POST_KEY, ['find', 'findOne'], document); | ||
return document; | ||
@@ -92,3 +95,4 @@ } | ||
document = this.toggleId(document, false); | ||
results.push(this.invokeEvents(POST_KEY, ['find', 'findMany'], document)); | ||
document = await this.invokeEvents(POST_KEY, ['find', 'findMany'], document); | ||
results.push(document); | ||
} | ||
@@ -101,3 +105,3 @@ | ||
const collection = await this.collection; | ||
document = this.invokeEvents(PRE_KEY, ['save', 'create'], document); | ||
document = await this.invokeEvents(PRE_KEY, ['save', 'create'], document); | ||
const res = await collection.insertOne(document); | ||
@@ -107,3 +111,3 @@ | ||
newDocument = this.toggleId(newDocument, false); | ||
newDocument = this.invokeEvents(POST_KEY, ['save', 'create'], newDocument); | ||
newDocument = await this.invokeEvents(POST_KEY, ['save', 'create'], newDocument); | ||
return newDocument; | ||
@@ -120,3 +124,3 @@ } | ||
const updates = this.invokeEvents(PRE_KEY, ['save'], document); | ||
const updates = await this.invokeEvents(PRE_KEY, ['save'], document); | ||
const res = await collection.updateOne({ _id: id }, { $set: updates }, { upsert: true }); | ||
@@ -134,3 +138,3 @@ let newDocument = await collection.findOne({ _id: id }); | ||
newDocument = this.invokeEvents(POST_KEY, ['save'], newDocument); | ||
newDocument = await this.invokeEvents(POST_KEY, ['save'], newDocument); | ||
return newDocument; | ||
@@ -149,3 +153,3 @@ } | ||
const collection = await this.collection; | ||
const updates = this.invokeEvents(PRE_KEY, ['update', 'updateOne'], req.updates); | ||
const updates = await this.invokeEvents(PRE_KEY, ['update', 'updateOne'], req.updates); | ||
@@ -157,3 +161,3 @@ const res = await collection | ||
document = this.toggleId(document, false); | ||
document = this.invokeEvents(POST_KEY, ['update', 'updateOne'], document); | ||
document = await this.invokeEvents(POST_KEY, ['update', 'updateOne'], document); | ||
return document; | ||
@@ -179,2 +183,1 @@ } | ||
} | ||
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
47310
587