Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | 5x 5x 5x 6x 6x 2x 6x 5x 5x | 'use strict';
import mongoose, {Model} from 'mongoose';
export default class CollectionsModelsMap {
public static addCollectionToModelMapping(model: Model<any>): void {
CollectionsModelsMap._models.set(model.collection.collectionName, model.modelName);
}
public static getModelByCollection(collectionName: string): Model<any> | null {
const modelName = CollectionsModelsMap._models.get(collectionName);
if (!modelName) return null;
return mongoose.model(modelName);
}
public static keys() {
return Array.from(CollectionsModelsMap._models.keys());
}
public static values() {
return Array.from(CollectionsModelsMap._models.values());
}
private static readonly _models: Map<string, string> = new Map<string, string>();
}
|