appwrite-utils-cli 0.0.243 → 0.0.245
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.
package/dist/migrations/users.js
CHANGED
@@ -52,13 +52,10 @@ export class UsersController {
|
|
52
52
|
return finalBatches;
|
53
53
|
};
|
54
54
|
const userPromises = [];
|
55
|
-
const
|
56
|
-
|
57
|
-
for (const user of userBatch) {
|
58
|
-
userPromises.push(this.users.delete(user.$id));
|
59
|
-
}
|
55
|
+
for (const user of allUsers) {
|
56
|
+
userPromises.push(this.users.delete(user.$id));
|
60
57
|
}
|
61
|
-
const batchedUserPromises =
|
58
|
+
const batchedUserPromises = createBatches(userPromises);
|
62
59
|
for (const batch of batchedUserPromises) {
|
63
60
|
console.log(`Deleting ${batch.length} users...`);
|
64
61
|
await Promise.all(batch);
|
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.245",
|
5
5
|
"main": "src/main.ts",
|
6
6
|
"type": "module",
|
7
7
|
"repository": {
|
package/src/migrations/users.ts
CHANGED
@@ -48,9 +48,9 @@ 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:
|
51
|
+
const createBatches = (finalData: any[]) => {
|
52
52
|
let maxBatchLength = 5;
|
53
|
-
const finalBatches:
|
53
|
+
const finalBatches: any[][] = [];
|
54
54
|
for (let i = 0; i < finalData.length; i++) {
|
55
55
|
if (i % maxBatchLength === 0) {
|
56
56
|
finalBatches.push([]);
|
@@ -60,13 +60,10 @@ export class UsersController {
|
|
60
60
|
return finalBatches;
|
61
61
|
};
|
62
62
|
const userPromises: Promise<string>[] = [];
|
63
|
-
const
|
64
|
-
|
65
|
-
for (const user of userBatch) {
|
66
|
-
userPromises.push(this.users.delete(user.$id));
|
67
|
-
}
|
63
|
+
for (const user of allUsers) {
|
64
|
+
userPromises.push(this.users.delete(user.$id));
|
68
65
|
}
|
69
|
-
const batchedUserPromises =
|
66
|
+
const batchedUserPromises = createBatches(userPromises);
|
70
67
|
for (const batch of batchedUserPromises) {
|
71
68
|
console.log(`Deleting ${batch.length} users...`);
|
72
69
|
await Promise.all(batch);
|