| 25 | import PluginInstaller from '../core/PluginInstaller'; |
| 26 | |
| 27 | class MongoosePlugin implements SwPlugin { |
| 28 | readonly module = 'mongoose'; |
| 29 | readonly versions = '*'; |
| 30 | mongodbEnabled?: boolean; |
| 31 | |
| 32 | install(installer: PluginInstaller): void { |
| 33 | const { Model } = installer.require?.('mongoose') ?? require('mongoose'); |
| 34 | |
| 35 | this.interceptOperation(Model, 'aggregate'); |
| 36 | this.interceptOperation(Model, 'bulkWrite'); |
| 37 | this.interceptOperation(Model, 'cleanIndexes'); |
| 38 | this.interceptOperation(Model, 'count'); |
| 39 | this.interceptOperation(Model, 'countDocuments'); |
| 40 | this.interceptOperation(Model, 'create'); |
| 41 | this.interceptOperation(Model, 'createCollection'); |
| 42 | this.interceptOperation(Model, 'createIndexes'); |
| 43 | this.interceptOperation(Model, 'deleteMany'); |
| 44 | this.interceptOperation(Model, 'deleteOne'); |
| 45 | this.interceptOperation(Model, 'distinct'); |
| 46 | this.interceptOperation(Model, 'ensureIndexes'); |
| 47 | this.interceptOperation(Model, 'estimatedDocumentCount'); |
| 48 | this.interceptOperation(Model, 'exists'); |
| 49 | |
| 50 | this.interceptOperation(Model, 'find'); |
| 51 | this.interceptOperation(Model, 'findById'); |
| 52 | this.interceptOperation(Model, 'findByIdAndDelete'); |
| 53 | this.interceptOperation(Model, 'findByIdAndRemove'); |
| 54 | this.interceptOperation(Model, 'findByIdAndUpdate'); |
| 55 | this.interceptOperation(Model, 'findOne'); |
| 56 | this.interceptOperation(Model, 'findOneAndDelete'); |
| 57 | this.interceptOperation(Model, 'findOneAndRemove'); |
| 58 | this.interceptOperation(Model, 'findOneAndReplace'); |
| 59 | this.interceptOperation(Model, 'findOneAndUpdate'); |
| 60 | |
| 61 | this.interceptOperation(Model, 'geoSearch'); |
| 62 | this.interceptOperation(Model, 'insertMany'); |
| 63 | this.interceptOperation(Model, 'listIndexes'); |
| 64 | this.interceptOperation(Model, 'mapReduce'); |
| 65 | this.interceptOperation(Model, 'populate'); |
| 66 | this.interceptOperation(Model, 'remove'); |
| 67 | this.interceptOperation(Model, 'replaceOne'); |
| 68 | this.interceptOperation(Model, 'syncIndexes'); |
| 69 | this.interceptOperation(Model, 'update'); |
| 70 | this.interceptOperation(Model, 'updateMany'); |
| 71 | this.interceptOperation(Model, 'updateOne'); |
| 72 | this.interceptOperation(Model, 'validate'); |
| 73 | |
| 74 | this.interceptOperation(Model.prototype, 'delete'); |
| 75 | this.interceptOperation(Model.prototype, 'deleteOne'); |
| 76 | this.interceptOperation(Model.prototype, 'remove'); |
| 77 | this.interceptOperation(Model.prototype, 'save'); |
| 78 | |
| 79 | // TODO: |
| 80 | // discriminator? |
| 81 | // startSession? |
| 82 | // where? |
| 83 | |
| 84 | // NODO: |
nothing calls this directly
no outgoing calls
no test coverage detected