Skip to content

Commit

Permalink
made adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
IslandRhythms committed Jul 19, 2023
1 parent 1e3c96f commit 6254c9c
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions test/model.create.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,18 +198,11 @@ describe('model', function() {
assert.equal(docs.length, 5);
});
it('should throw an error only after all the documents have finished saving gh-4628', async function() {
const countSchema = new Schema({ n: Number });
const testSchema = new Schema({ name: { type: String, unique: true }, reference: Number });
const testSchema = new Schema({ name: { type: String, unique: true } });

const Count = db.model('gh4628', countSchema);

testSchema.pre('save', async function(next) {
const doc = await Count.findOneAndUpdate({}, { $inc: { n: 1 } }, { new: true, upsert: true });
this.reference = doc.n;
next();
});

const Test = db.model('gh4628Test', testSchema);
await Test.init();
const data = [];
for (let i = 0; i < 11; i++) {
data.push({ name: 'Test' + Math.abs(i - 4) });
Expand Down

0 comments on commit 6254c9c

Please sign in to comment.