Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Sep 10, 2024
1 parent 599dc13 commit e13fc38
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions test/docs/transactions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -567,43 +567,38 @@ describe('transactions', function() {

it('transaction() avoids duplicating atomic operations (gh-14848)', async function() {
db.deleteModel(/Test/);
// Define some schemas...
const subItemSchema = new mongoose.Schema(
{
name: { type: String, required: true },
{
name: { type: String, required: true }
},
{ _id: false }
);

const itemSchema = new mongoose.Schema(
{
name: { type: String, required: true },
subItems: { type: [subItemSchema], required: true },
subItems: { type: [subItemSchema], required: true }
},
{ _id: false }
);

const schema = new mongoose.Schema({
items: { type: [itemSchema], required: true },
items: { type: [itemSchema], required: true }
});

// ...and a model
const Test = db.model("Test", schema);
const Test = db.model('Test', schema);


await Test.createCollection();
await Test.deleteMany({});

const { _id } = await Test.create({
items: [
{ name: "test1", subItems: [{ name: "x1" }] },
{ name: "test2", subItems: [{ name: "x2" }] },
],
{ name: 'test1', subItems: [{ name: 'x1' }] },
{ name: 'test2', subItems: [{ name: 'x2' }] }
]
});

let doc = await Test.findById(_id);
doc.items.push({ name: "test3", subItems: [{ name: "x3" }] });

doc.items.push({ name: 'test3', subItems: [{ name: 'x3' }] });

let i = 0;
await db.transaction(async(session) => {
Expand All @@ -616,7 +611,7 @@ describe('transactions', function() {
});

assert.equal(i, 3);

doc = await Test.findById(_id);
assert.equal(doc.items.length, 3);
});
Expand Down

0 comments on commit e13fc38

Please sign in to comment.