Skip to content

Commit

Permalink
- Error Handling BUGs Fixed and Tested (Should be Working Now)
Browse files Browse the repository at this point in the history
- mongodb version upgraded to 6.3.0
- TS config changes.
- Changelog updated.
  • Loading branch information
loeiks committed Feb 20, 2024
1 parent 6e50ecd commit b826a81
Show file tree
Hide file tree
Showing 76 changed files with 326 additions and 303 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: "🚀 Deploy New Version"

on:
push:
branches:
- main
workflow_dispatch:
release:
types: [created]

jobs:
install:
Expand Down
25 changes: 16 additions & 9 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,22 @@ In this file you can find what's changed in each version. (Versions with -dev, -

---

### 2.8.X
### 2.8.2

- Error Handling BUGs Fixed and Tested (Should be Working Now)
- mongodb version upgraded to 6.3.0
- TS config changes.
- Changelog updated.

### 2.8.1

- Error Handling Fixes for All Functions
- Error Message Fixes for All Functions
- Default DB Named Changed as "ExWeiv"
- Docs Updated
- BUG Fixes

### 2.8.0

- BUG Fixes
- New Helper Functions (findOne, getAndRemove, getAndReplace, getAndUpdate)
Expand All @@ -17,14 +32,6 @@ In this file you can find what's changed in each version. (Versions with -dev, -
- TS Should be Working on VSCode (Auto-complete etc.)
- Library Info Updated

#### 2.8.1

- Error Handling Fixes for All Functions
- Error Message Fixes for All Functions
- Default DB Named Changed as "ExWeiv"
- Docs Updated
- BUG Fixes

### 2.7.X

- BUG Fixes
Expand Down
6 changes: 3 additions & 3 deletions app/lib/Functions/bulkInsert.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ async function bulkInsert(collectionId, items, options) {
};
});
const { collection } = await (0, connection_helpers_1.connectionHandler)(collectionId, suppressAuth);
const { insertedIds, insertedCount, hasWriteErrors, getWriteErrors } = await collection.bulkWrite(writeOperations, { readConcern: consistentRead === true ? "majority" : "local", ordered: true });
const { insertedIds, insertedCount, ok } = await collection.bulkWrite(writeOperations, { readConcern: consistentRead === true ? "majority" : "local", ordered: true });
const insertedItemIds = Object.keys(insertedIds).map((key) => {
return insertedIds[key];
});
if (!hasWriteErrors()) {
if (ok) {
if (suppressHooks != true) {
editedItems = editedItems.map(async (item) => {
const editedInsertItem = await (0, hook_manager_1.runDataHook)(collectionId, "afterInsert", [item, context]).catch((err) => {
Expand All @@ -58,7 +58,7 @@ async function bulkInsert(collectionId, items, options) {
return { insertedItems: editedItems, insertedItemIds, inserted: insertedCount };
}
else {
throw Error(`WeivData - Error when inserting items using bulkInsert, inserted: ${insertedCount}, write errors: ${getWriteErrors()}`);
throw Error(`WeivData - Error when inserting items using bulkInsert, inserted: ${insertedCount}, ok: ${ok}`);
}
}
catch (err) {
Expand Down
6 changes: 3 additions & 3 deletions app/lib/Functions/bulkRemove.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ async function bulkRemove(collectionId, itemIds, options) {
};
});
const { collection } = await (0, connection_helpers_1.connectionHandler)(collectionId, suppressAuth);
const { deletedCount, hasWriteErrors, getWriteErrors } = await collection.bulkWrite(writeOperations, { readConcern: consistentRead === true ? "majority" : "local", ordered: true });
if (!hasWriteErrors()) {
const { deletedCount, ok } = await collection.bulkWrite(writeOperations, { readConcern: consistentRead === true ? "majority" : "local", ordered: true });
if (ok) {
return {
removed: deletedCount,
removedItemIds: editedItemIds
};
}
else {
throw Error(`WeivData - Error when removing items using bulkRemove: removed: ${deletedCount}, write errors: ${getWriteErrors()}`);
throw Error(`WeivData - Error when removing items using bulkRemove: removed: ${deletedCount}, ok: ${ok}`);
}
}
catch (err) {
Expand Down
6 changes: 3 additions & 3 deletions app/lib/Functions/bulkSave.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ async function bulkSave(collectionId, items, options) {
}
});
const { collection } = await (0, connection_helpers_1.connectionHandler)(collectionId, suppressAuth);
const { insertedCount, modifiedCount, insertedIds, hasWriteErrors, getWriteErrors } = await collection.bulkWrite(bulkOperations, { readConcern: consistentRead === true ? "majority" : "local", ordered: true });
if (!hasWriteErrors()) {
const { insertedCount, modifiedCount, insertedIds, ok } = await collection.bulkWrite(bulkOperations, { readConcern: consistentRead === true ? "majority" : "local", ordered: true });
if (ok) {
if (suppressHooks != true) {
editedItems = editedItems.map(async (item) => {
if (item._id) {
Expand Down Expand Up @@ -112,7 +112,7 @@ async function bulkSave(collectionId, items, options) {
};
}
else {
throw Error(`WeivData - Error when saving items using bulkSave: inserted: ${insertedCount}, updated: ${modifiedCount}, write errors: ${getWriteErrors()}`);
throw Error(`WeivData - Error when saving items using bulkSave: inserted: ${insertedCount}, updated: ${modifiedCount}, ok: ${ok}`);
}
}
catch (err) {
Expand Down
6 changes: 3 additions & 3 deletions app/lib/Functions/bulkUpdate.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ async function bulkUpdate(collectionId, items, options) {
};
});
const { collection } = await (0, connection_helpers_1.connectionHandler)(collectionId, suppressAuth);
const { modifiedCount, hasWriteErrors, getWriteErrors } = await collection.bulkWrite(bulkOperations, { readConcern: consistentRead === true ? "majority" : "local", ordered: true });
if (!hasWriteErrors()) {
const { modifiedCount, ok } = await collection.bulkWrite(bulkOperations, { readConcern: consistentRead === true ? "majority" : "local", ordered: true });
if (ok) {
if (suppressHooks != true) {
editedItems = editedItems.map(async (item) => {
const editedItem = await (0, hook_manager_1.runDataHook)(collectionId, "afterUpdate", [item, context]).catch((err) => {
Expand All @@ -66,7 +66,7 @@ async function bulkUpdate(collectionId, items, options) {
};
}
else {
throw Error(`WeivData - Error when updating items using bulkUpdate: updated: ${modifiedCount}, write errors: ${getWriteErrors()}`);
throw Error(`WeivData - Error when updating items using bulkUpdate: updated: ${modifiedCount}, ok: ${ok}`);
}
}
catch (err) {
Expand Down
Loading

0 comments on commit b826a81

Please sign in to comment.