@stenneepro/mongoose-soft-delete
Version:
Mongoose soft delete plugin
18 lines (14 loc) • 380 B
text/typescript
import DeletedSchema from './types/DeletedSchema';
export default function(
schema: DeletedSchema
): void {
schema.query.withDeleted = function() {
return this.setOptions({ ignoreDeleted: true });
};
schema.query.notDeleted = function() {
return this.where({ deleted: false });
};
schema.query.onlyDeleted = function() {
return this.where({ deleted: true });
};
}