Skip to content

Commit

Permalink
Merge pull request #42 from lowdefy/feat-mongodb-insert-many
Browse files Browse the repository at this point in the history
feat(plugin-mongodb): Update MongoDBInsertMany to return insertedIds.
  • Loading branch information
Gervwyk authored Feb 1, 2024
2 parents 93daefb + 5fc778b commit 84adc43
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/angry-terms-invent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@lowdefy/community-plugin-mongodb': minor
---

Update MongoDBInsertMany to return insertedIds.
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ async function MongodbInsertMany({
throw error;
}
await client.close();
const { acknowledged, insertedCount } = serialize(response);
return { acknowledged, insertedCount };
const { acknowledged, insertedCount, insertedIds } = serialize(response);
return { acknowledged, insertedCount, insertedIds };
}

MongodbInsertMany.schema = schema;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ test('insertMany', async () => {
expect(res).toEqual({
acknowledged: true,
insertedCount: 3,
insertedIds: { 0: 'insertMany1-1', 1: 'insertMany1-2', 2: 'insertMany1-3' },
});
});

Expand Down Expand Up @@ -75,6 +76,7 @@ test('insertMany logCollection', async () => {
expect(res).toEqual({
acknowledged: true,
insertedCount: 3,
insertedIds: { 0: 'insertMany1-1_log', 1: 'insertMany1-2_log', 2: 'insertMany1-3_log' },
});
const logged = await findLogCollectionRecordTestMongoDb({
logCollection,
Expand Down Expand Up @@ -106,6 +108,7 @@ test('insertMany options', async () => {
expect(res).toEqual({
acknowledged: true,
insertedCount: 2,
insertedIds: { 0: 'insertMany2-1', 1: 'insertMany2-2' },
});
});

Expand Down Expand Up @@ -133,6 +136,7 @@ test('insertMany logCollection options', async () => {
expect(res).toEqual({
acknowledged: true,
insertedCount: 2,
insertedIds: { 0: 'insertMany2-1_log', 1: 'insertMany2-2_log' },
});
const logged = await findLogCollectionRecordTestMongoDb({
logCollection,
Expand Down

0 comments on commit 84adc43

Please sign in to comment.