appwrite-utils-cli 0.0.43 → 0.0.44

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -154,20 +154,26 @@ export class ImportController {
154
154
  const batches = dataSplit[i];
155
155
  console.log(`Processing batch ${i + 1} of ${dataSplit.length}`);
156
156
  const batchPromises = batches.map((item) => {
157
- const id = item.finalData.docId ||
158
- item.finalData.userId ||
159
- item.context.docId ||
160
- item.context.userId;
161
- if (item.finalData.hasOwnProperty("userId")) {
162
- delete item.finalData.userId;
163
- }
164
- if (item.finalData.hasOwnProperty("docId")) {
165
- delete item.finalData.docId;
157
+ try {
158
+ const id = item.finalData.docId ||
159
+ item.finalData.userId ||
160
+ item.context.docId ||
161
+ item.context.userId;
162
+ if (item.finalData.hasOwnProperty("userId")) {
163
+ delete item.finalData.userId;
164
+ }
165
+ if (item.finalData.hasOwnProperty("docId")) {
166
+ delete item.finalData.docId;
167
+ }
168
+ if (!item.finalData) {
169
+ return Promise.resolve();
170
+ }
171
+ return tryAwaitWithRetry(async () => await this.database.createDocument(db.$id, collection.$id, id, item.finalData));
166
172
  }
167
- if (!item.finalData) {
173
+ catch (error) {
174
+ console.error(error);
168
175
  return Promise.resolve();
169
176
  }
170
- return tryAwaitWithRetry(async () => await this.database.createDocument(db.$id, collection.$id, id, item.finalData));
171
177
  });
172
178
  // Wait for all promises in the current batch to resolve
173
179
  await Promise.all(batchPromises);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "appwrite-utils-cli",
3
3
  "description": "Appwrite Utility Functions to help with database management, data conversion, data import, migrations, and much more. Meant to be used as a CLI tool, I do not recommend installing this in frontend environments.",
4
- "version": "0.0.43",
4
+ "version": "0.0.44",
5
5
  "main": "src/main.ts",
6
6
  "type": "module",
7
7
  "repository": {
@@ -220,29 +220,34 @@ export class ImportController {
220
220
  const batches = dataSplit[i];
221
221
  console.log(`Processing batch ${i + 1} of ${dataSplit.length}`);
222
222
  const batchPromises = batches.map((item) => {
223
- const id =
224
- item.finalData.docId ||
225
- item.finalData.userId ||
226
- item.context.docId ||
227
- item.context.userId;
228
- if (item.finalData.hasOwnProperty("userId")) {
229
- delete item.finalData.userId;
230
- }
231
- if (item.finalData.hasOwnProperty("docId")) {
232
- delete item.finalData.docId;
233
- }
234
- if (!item.finalData) {
223
+ try {
224
+ const id =
225
+ item.finalData.docId ||
226
+ item.finalData.userId ||
227
+ item.context.docId ||
228
+ item.context.userId;
229
+ if (item.finalData.hasOwnProperty("userId")) {
230
+ delete item.finalData.userId;
231
+ }
232
+ if (item.finalData.hasOwnProperty("docId")) {
233
+ delete item.finalData.docId;
234
+ }
235
+ if (!item.finalData) {
236
+ return Promise.resolve();
237
+ }
238
+ return tryAwaitWithRetry(
239
+ async () =>
240
+ await this.database.createDocument(
241
+ db.$id,
242
+ collection.$id,
243
+ id,
244
+ item.finalData
245
+ )
246
+ );
247
+ } catch (error) {
248
+ console.error(error);
235
249
  return Promise.resolve();
236
250
  }
237
- return tryAwaitWithRetry(
238
- async () =>
239
- await this.database.createDocument(
240
- db.$id,
241
- collection.$id,
242
- id,
243
- item.finalData
244
- )
245
- );
246
251
  });
247
252
  // Wait for all promises in the current batch to resolve
248
253
  await Promise.all(batchPromises);