Skip to content

Commit 9e3f604

Browse files
authored
Merge pull request #18 from nour-karoui/feat/update-mongoose
Upgrade mongoose to 7.6.1 and update README
2 parents ead24d8 + 6a7e847 commit 9e3f604

3 files changed

Lines changed: 305 additions & 503 deletions

File tree

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ const TestSchema = new Schema({
4444
});
4545

4646
TestSchema.plugin(softDeletePlugin);
47-
const Test = mongoose.model("Test", TestSchema);
47+
const TestModel = mongoose.model("Test", TestSchema);
4848

49-
const test = new Test({name: 'hello', lastName: "world"});
49+
const test = new TestModel({name: 'hello', lastName: "world"});
5050

5151
/*** returns an object containing the number of softDeleted elements ***/
5252
/***
@@ -56,7 +56,7 @@ const test = new Test({name: 'hello', lastName: "world"});
5656
the argument options is optional
5757
***/
5858
const options = { validateBeforeSave: false };
59-
const deleted = await Test.softDelete({ _id: test._id, name: test.name }, options);
59+
const deleted = await TestModel.softDelete({ _id: test._id, name: test.name }, options);
6060
/**
6161
const deleted = await Test.softDelete({ _id: test._id, name: test.name }); is also valid
6262
**/
@@ -65,16 +65,16 @@ const deleted = await Test.softDelete({ _id: test._id, name: test.name }, option
6565
/***
6666
{restored: number}
6767
***/
68-
const restored = await Test.restore({ _id: test._id, name: test.name });
68+
const restored = await TestModel.restore({ _id: test._id, name: test.name });
6969

7070
/*** returns all deleted elements ***/
71-
const deletedElements = await Test.findDeleted();
71+
const deletedElements = await TestModel.findDeleted();
7272

7373
/*** returns all available elements (not deleted) ***/
74-
const availableElements = await Test.find();
74+
const availableElements = await TestModel.find();
7575

7676
/*** counts all available elements (not deleted) ***/
77-
const countAvailable = await Test.count();
77+
const countAvailable = await TestModel.count();
7878

7979
/*** findById returns the document whether deleted or not ***/
8080
```
@@ -111,7 +111,7 @@ const test = await new this.testModel({name: 'hello', lastName: 'world'});
111111
the argument options is optional
112112
***/
113113
const options = { validateBeforeSave: false };
114-
const deleted = await Test.softDelete({ _id: test._id, name: test.name }, options);
114+
const deleted = await this.testModel.softDelete({ _id: test._id, name: test.name }, options);
115115
/**
116116
const deleted = await Test.softDelete({ _id: test._id, name: test.name }); is also valid
117117
**/
@@ -129,7 +129,7 @@ const deletedElements = await this.testModel.findDeleted();
129129
const availableElements = await this.testModel.find();
130130

131131
/*** counts all available elements (not deleted) ***/
132-
const countAvailable = await Test.count();
132+
const countAvailable = await this.test.count();
133133

134134
/*** findById returns the document whether deleted or not ***/
135135
```

0 commit comments

Comments
 (0)