()
| 40 | } |
| 41 | |
| 42 | async onModuleInit() { |
| 43 | if (this.enableFullCache) { |
| 44 | this.logger.log(`Caching all ${this.model.modelName}s`) |
| 45 | const docs = await this.model.find().exec() |
| 46 | docs.forEach((doc) => this.docsCache.set(doc.id, doc)) |
| 47 | this.useFullCache = true |
| 48 | this.logger.log(`Cached ${this.docsCache.size} ${this.model.modelName}s`) |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | async query(query: Query<T>): Promise<T[]> { |
| 53 | // if a search was given, include it on the filter |