appwrite-utils-cli 0.0.22 → 0.0.24
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/README.md
CHANGED
|
@@ -81,6 +81,7 @@ This setup ensures that developers have robust tools at their fingertips to mana
|
|
|
81
81
|
|
|
82
82
|
### Changelog
|
|
83
83
|
|
|
84
|
+
- 0.0.23: Added batching to user deletion
|
|
84
85
|
- 0.0.22: Converted all import processes except `postImportActions` and Relationship Resolution to the local data import, so it should be much faster.
|
|
85
86
|
- 0.0.6: Added `setTargetFieldFromOtherCollectionDocumentsByMatchingField` for the below, but setting a different field than the field you matched. The names are long, but at least you know what's going on lmao.
|
|
86
87
|
- 0.0.5: Added `setFieldFromOtherCollectionDocuments` to set an array of ID's for instance from another collection as a `postImportAction`
|
|
@@ -164,5 +164,5 @@ export declare const findOrCreateOperation: (database: Databases, collectionId:
|
|
|
164
164
|
}>;
|
|
165
165
|
export declare const updateOperation: (database: Databases, operationId: string, updateFields: any) => Promise<void>;
|
|
166
166
|
export declare const maxDataLength = 1073741820;
|
|
167
|
-
export declare const maxBatchItems =
|
|
167
|
+
export declare const maxBatchItems = 50;
|
|
168
168
|
export declare const splitIntoBatches: (data: any[]) => any[][];
|
|
@@ -94,7 +94,7 @@ export const updateOperation = async (database, operationId, updateFields) => {
|
|
|
94
94
|
};
|
|
95
95
|
// Actual max 1073741824
|
|
96
96
|
export const maxDataLength = 1073741820;
|
|
97
|
-
export const maxBatchItems =
|
|
97
|
+
export const maxBatchItems = 50;
|
|
98
98
|
export const splitIntoBatches = (data) => {
|
|
99
99
|
let batches = [];
|
|
100
100
|
let currentBatch = [];
|
package/dist/migrations/users.js
CHANGED
|
@@ -2,6 +2,7 @@ import { Databases, ID, Query, Users } from "node-appwrite";
|
|
|
2
2
|
import { AuthUserSchema, } from "../schemas/authUser.js";
|
|
3
3
|
import _ from "lodash";
|
|
4
4
|
import { logger } from "./logging.js";
|
|
5
|
+
import { splitIntoBatches } from "./migrationHelper.js";
|
|
5
6
|
export class UsersController {
|
|
6
7
|
config;
|
|
7
8
|
users;
|
|
@@ -39,8 +40,13 @@ export class UsersController {
|
|
|
39
40
|
lastDocumentId = moreUsers.users[moreUsers.users.length - 1].$id;
|
|
40
41
|
}
|
|
41
42
|
console.log("Deleting all users");
|
|
43
|
+
const userPromises = [];
|
|
42
44
|
for (const user of allUsers) {
|
|
43
|
-
|
|
45
|
+
userPromises.push(this.users.delete(user.$id));
|
|
46
|
+
}
|
|
47
|
+
const batchedUserPromises = splitIntoBatches(userPromises);
|
|
48
|
+
for (const batch of batchedUserPromises) {
|
|
49
|
+
await Promise.all(batch);
|
|
44
50
|
}
|
|
45
51
|
}
|
|
46
52
|
async getAllUsers() {
|
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.24",
|
|
5
5
|
"main": "src/main.ts",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"repository": {
|
|
@@ -158,7 +158,7 @@ export const updateOperation = async (
|
|
|
158
158
|
|
|
159
159
|
// Actual max 1073741824
|
|
160
160
|
export const maxDataLength = 1073741820;
|
|
161
|
-
export const maxBatchItems =
|
|
161
|
+
export const maxBatchItems = 50;
|
|
162
162
|
|
|
163
163
|
export const splitIntoBatches = (data: any[]): any[][] => {
|
|
164
164
|
let batches = [];
|
package/src/migrations/users.ts
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
} from "../schemas/authUser.js";
|
|
8
8
|
import _ from "lodash";
|
|
9
9
|
import { logger } from "./logging.js";
|
|
10
|
+
import { splitIntoBatches } from "./migrationHelper.js";
|
|
10
11
|
|
|
11
12
|
export class UsersController {
|
|
12
13
|
private config: AppwriteConfig;
|
|
@@ -47,8 +48,13 @@ export class UsersController {
|
|
|
47
48
|
lastDocumentId = moreUsers.users[moreUsers.users.length - 1].$id;
|
|
48
49
|
}
|
|
49
50
|
console.log("Deleting all users");
|
|
51
|
+
const userPromises: Promise<string>[] = [];
|
|
50
52
|
for (const user of allUsers) {
|
|
51
|
-
|
|
53
|
+
userPromises.push(this.users.delete(user.$id));
|
|
54
|
+
}
|
|
55
|
+
const batchedUserPromises = splitIntoBatches(userPromises);
|
|
56
|
+
for (const batch of batchedUserPromises) {
|
|
57
|
+
await Promise.all(batch);
|
|
52
58
|
}
|
|
53
59
|
}
|
|
54
60
|
|