appwrite-utils-cli 0.0.242 → 0.0.243
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.
@@ -71,7 +71,7 @@ export const wipeDocumentStorage = async (storage, config, dbName) => {
|
|
71
71
|
const fileIds = filesPulled.files.map((file) => file.$id);
|
72
72
|
allFiles.push(...fileIds);
|
73
73
|
}
|
74
|
-
moreFiles = filesPulled.files.length
|
74
|
+
moreFiles = filesPulled.files.length === 100; // Adjust based on the limit
|
75
75
|
if (moreFiles) {
|
76
76
|
lastFileId = filesPulled.files[filesPulled.files.length - 1].$id;
|
77
77
|
}
|
package/dist/migrations/users.js
CHANGED
@@ -40,8 +40,19 @@ export class UsersController {
|
|
40
40
|
lastDocumentId = moreUsers.users[moreUsers.users.length - 1].$id;
|
41
41
|
}
|
42
42
|
console.log("Deleting all users...");
|
43
|
+
const createBatches = (finalData) => {
|
44
|
+
let maxBatchLength = 5;
|
45
|
+
const finalBatches = [];
|
46
|
+
for (let i = 0; i < finalData.length; i++) {
|
47
|
+
if (i % maxBatchLength === 0) {
|
48
|
+
finalBatches.push([]);
|
49
|
+
}
|
50
|
+
finalBatches[finalBatches.length - 1].push(finalData[i]);
|
51
|
+
}
|
52
|
+
return finalBatches;
|
53
|
+
};
|
43
54
|
const userPromises = [];
|
44
|
-
const allUsersBatched =
|
55
|
+
const allUsersBatched = createBatches(allUsers);
|
45
56
|
for (const userBatch of allUsersBatched) {
|
46
57
|
for (const user of userBatch) {
|
47
58
|
userPromises.push(this.users.delete(user.$id));
|
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.
|
4
|
+
"version": "0.0.243",
|
5
5
|
"main": "src/main.ts",
|
6
6
|
"type": "module",
|
7
7
|
"repository": {
|
@@ -111,7 +111,7 @@ export const wipeDocumentStorage = async (
|
|
111
111
|
const fileIds = filesPulled.files.map((file) => file.$id);
|
112
112
|
allFiles.push(...fileIds);
|
113
113
|
}
|
114
|
-
moreFiles = filesPulled.files.length
|
114
|
+
moreFiles = filesPulled.files.length === 100; // Adjust based on the limit
|
115
115
|
if (moreFiles) {
|
116
116
|
lastFileId = filesPulled.files[filesPulled.files.length - 1].$id;
|
117
117
|
}
|
package/src/migrations/users.ts
CHANGED
@@ -48,8 +48,19 @@ export class UsersController {
|
|
48
48
|
lastDocumentId = moreUsers.users[moreUsers.users.length - 1].$id;
|
49
49
|
}
|
50
50
|
console.log("Deleting all users...");
|
51
|
+
const createBatches = (finalData: Models.User<Models.Preferences>[]) => {
|
52
|
+
let maxBatchLength = 5;
|
53
|
+
const finalBatches: Models.User<Models.Preferences>[][] = [];
|
54
|
+
for (let i = 0; i < finalData.length; i++) {
|
55
|
+
if (i % maxBatchLength === 0) {
|
56
|
+
finalBatches.push([]);
|
57
|
+
}
|
58
|
+
finalBatches[finalBatches.length - 1].push(finalData[i]);
|
59
|
+
}
|
60
|
+
return finalBatches;
|
61
|
+
};
|
51
62
|
const userPromises: Promise<string>[] = [];
|
52
|
-
const allUsersBatched =
|
63
|
+
const allUsersBatched = createBatches(allUsers);
|
53
64
|
for (const userBatch of allUsersBatched) {
|
54
65
|
for (const user of userBatch) {
|
55
66
|
userPromises.push(this.users.delete(user.$id));
|