diff --git a/.changeset/angry-terms-invent.md b/.changeset/angry-terms-invent.md new file mode 100644 index 0000000..d14350e --- /dev/null +++ b/.changeset/angry-terms-invent.md @@ -0,0 +1,5 @@ +--- +'@lowdefy/community-plugin-mongodb': minor +--- + +Update MongoDBInsertMany to return insertedIds. diff --git a/plugins/community-plugin-mongodb/src/connections/MongoDBCollection/MongoDBInsertMany/MongoDBInsertMany.js b/plugins/community-plugin-mongodb/src/connections/MongoDBCollection/MongoDBInsertMany/MongoDBInsertMany.js index c4f1f61..eda5a44 100644 --- a/plugins/community-plugin-mongodb/src/connections/MongoDBCollection/MongoDBInsertMany/MongoDBInsertMany.js +++ b/plugins/community-plugin-mongodb/src/connections/MongoDBCollection/MongoDBInsertMany/MongoDBInsertMany.js @@ -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; diff --git a/plugins/community-plugin-mongodb/src/connections/MongoDBCollection/MongoDBInsertMany/MongoDBInsertMany.test.js b/plugins/community-plugin-mongodb/src/connections/MongoDBCollection/MongoDBInsertMany/MongoDBInsertMany.test.js index 2212954..53afac4 100644 --- a/plugins/community-plugin-mongodb/src/connections/MongoDBCollection/MongoDBInsertMany/MongoDBInsertMany.test.js +++ b/plugins/community-plugin-mongodb/src/connections/MongoDBCollection/MongoDBInsertMany/MongoDBInsertMany.test.js @@ -45,6 +45,7 @@ test('insertMany', async () => { expect(res).toEqual({ acknowledged: true, insertedCount: 3, + insertedIds: { 0: 'insertMany1-1', 1: 'insertMany1-2', 2: 'insertMany1-3' }, }); }); @@ -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, @@ -106,6 +108,7 @@ test('insertMany options', async () => { expect(res).toEqual({ acknowledged: true, insertedCount: 2, + insertedIds: { 0: 'insertMany2-1', 1: 'insertMany2-2' }, }); }); @@ -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,