Skip to content

Commit 80107ae

Browse files
committed
fix: catch parse error on multi insert
1 parent aa9fd52 commit 80107ae

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

packages/compass-crud/src/stores/crud-store.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1345,19 +1345,19 @@ class CrudStoreImpl
13451345
* Insert a single document.
13461346
*/
13471347
async insertMany() {
1348-
const docs = HadronDocument.FromEJSONArray(
1349-
this.state.insert.jsonDoc ?? ''
1350-
).map((doc) => doc.generateObject());
1351-
this.track(
1352-
'Document Inserted',
1353-
{
1354-
mode: this.state.insert.jsonView ? 'json' : 'field-by-field',
1355-
multiple: docs.length > 1,
1356-
},
1357-
this.connectionInfoRef.current
1358-
);
1359-
13601348
try {
1349+
const docs = HadronDocument.FromEJSONArray(
1350+
this.state.insert.jsonDoc ?? ''
1351+
).map((doc) => doc.generateObject());
1352+
this.track(
1353+
'Document Inserted',
1354+
{
1355+
mode: this.state.insert.jsonView ? 'json' : 'field-by-field',
1356+
multiple: docs.length > 1,
1357+
},
1358+
this.connectionInfoRef.current
1359+
);
1360+
13611361
await this.dataService.insertMany(this.state.ns, docs);
13621362
// track mode for analytics events
13631363
const payload = {

0 commit comments

Comments
 (0)