Skip to content

Commit

Permalink
add test gh-11106
Browse files Browse the repository at this point in the history
  • Loading branch information
rpenido committed Dec 15, 2021
1 parent c473f91 commit b71e551
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions test/model.update.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3237,6 +3237,20 @@ describe('model: updateOne: ', function() {
assert.strictEqual(doc.newProp, void 0);
});

it('update pipeline - $unset with string (gh-11106)', async function() {
const schema = Schema({ oldProp: String, newProp: String });
const Model = db.model('Test', schema);

await Model.create({ oldProp: 'test' });
await Model.updateOne({}, [
{ $set: { newProp: 'test2' } },
{ $unset: 'oldProp' }
]);
const doc = await Model.findOne();
assert.equal(doc.newProp, 'test2');
assert.strictEqual(doc.oldProp, void 0);
});

it('update pipeline timestamps (gh-8524)', async function() {
const Cat = db.model('Test', Schema({ name: String }, { timestamps: true }));

Expand Down

0 comments on commit b71e551

Please sign in to comment.