i am using Mongoose v7.x in my nestJS projec, i want to use pre hook with where condition like this:
const schema = JsonSchemaSchema;
//Pre middleware will apply on any Query middleware that start with find or update or delete)
schema.pre(new RegExp('(find|update|delete)'), function () {
this.where({
...buildNotDeletedCondition(),
...authorizationService.buildEntitiesAuthCondition(),
});
});
but i am geeting the following error:
` Property 'where' does not exist on type '(Document> & Omit & Required<{ _id: ObjectId; }>, never>) | Query<...>'. Did you mean '$where'?
Property 'where' does not exist on type 'Document> & Omit & Required<{ _id: ObjectId; }>, never>'.
12 this.where({
~~~~~
`
my code work fine in mongoose v6. anyone know how i could solve this?
Top comments (0)