appwrite-utils-cli 0.0.253 → 0.0.255
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.253: Added `--writeData` (or `--write-data`) to command to write the output of the import data to a file called dataLoaderOutput in your root dir
|
84
85
|
- 0.0.23: Added batching to user deletion
|
85
86
|
- 0.0.22: Converted all import processes except `postImportActions` and Relationship Resolution to the local data import, so it should be much faster.
|
86
87
|
- 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.
|
@@ -647,7 +647,6 @@ export class DataLoader {
|
|
647
647
|
finalData: transformedData,
|
648
648
|
});
|
649
649
|
this.importMap.set(this.getCollectionKey(collection.name), currentData);
|
650
|
-
console.log(`Set import map for ${collection.name}, length is ${currentData.data.length}`);
|
651
650
|
this.oldIdToNewIdPerCollectionMap.set(this.getCollectionKey(collection.name), collectionOldIdToNewIdMap);
|
652
651
|
}
|
653
652
|
else {
|
@@ -100,16 +100,17 @@ export class ImportController {
|
|
100
100
|
if (userBatch.finalData && userBatch.finalData.length > 0) {
|
101
101
|
const userId = userBatch.finalData.userId;
|
102
102
|
if (dataLoader.userExistsMap.has(userId)) {
|
103
|
-
|
103
|
+
// We only are storing the existing user ID's as true, so we need to check for that
|
104
|
+
if (!(dataLoader.userExistsMap.get(userId) === true)) {
|
104
105
|
return usersController
|
105
106
|
.createUserAndReturn(userBatch.finalData)
|
106
107
|
.then(() => console.log("Created user"))
|
107
108
|
.catch((error) => {
|
108
109
|
logger.error("Error creating user:", error, "\nUser data is ", userBatch.finalData);
|
109
|
-
throw error;
|
110
110
|
});
|
111
111
|
}
|
112
112
|
else {
|
113
|
+
console.log("Skipped existing user: ", userId);
|
113
114
|
return Promise.resolve();
|
114
115
|
}
|
115
116
|
}
|
@@ -123,8 +124,8 @@ export class ImportController {
|
|
123
124
|
console.log("Finished importing users");
|
124
125
|
}
|
125
126
|
}
|
126
|
-
if (!importOperationId
|
127
|
-
// Skip further processing
|
127
|
+
if (!importOperationId) {
|
128
|
+
// Skip further processing if no import operation is found
|
128
129
|
continue;
|
129
130
|
}
|
130
131
|
const importOperation = await this.database.getDocument("migrations", "currentOperations", importOperationId);
|
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.255",
|
5
5
|
"main": "src/main.ts",
|
6
6
|
"type": "module",
|
7
7
|
"repository": {
|
@@ -858,9 +858,6 @@ export class DataLoader {
|
|
858
858
|
finalData: transformedData,
|
859
859
|
});
|
860
860
|
this.importMap.set(this.getCollectionKey(collection.name), currentData);
|
861
|
-
console.log(
|
862
|
-
`Set import map for ${collection.name}, length is ${currentData.data.length}`
|
863
|
-
);
|
864
861
|
this.oldIdToNewIdPerCollectionMap.set(
|
865
862
|
this.getCollectionKey(collection.name),
|
866
863
|
collectionOldIdToNewIdMap!
|
@@ -160,7 +160,8 @@ export class ImportController {
|
|
160
160
|
if (userBatch.finalData && userBatch.finalData.length > 0) {
|
161
161
|
const userId = userBatch.finalData.userId;
|
162
162
|
if (dataLoader.userExistsMap.has(userId)) {
|
163
|
-
|
163
|
+
// We only are storing the existing user ID's as true, so we need to check for that
|
164
|
+
if (!(dataLoader.userExistsMap.get(userId) === true)) {
|
164
165
|
return usersController
|
165
166
|
.createUserAndReturn(userBatch.finalData)
|
166
167
|
.then(() => console.log("Created user"))
|
@@ -171,9 +172,9 @@ export class ImportController {
|
|
171
172
|
"\nUser data is ",
|
172
173
|
userBatch.finalData
|
173
174
|
);
|
174
|
-
throw error;
|
175
175
|
});
|
176
176
|
} else {
|
177
|
+
console.log("Skipped existing user: ", userId);
|
177
178
|
return Promise.resolve();
|
178
179
|
}
|
179
180
|
}
|
@@ -190,8 +191,8 @@ export class ImportController {
|
|
190
191
|
}
|
191
192
|
}
|
192
193
|
|
193
|
-
if (!importOperationId
|
194
|
-
// Skip further processing
|
194
|
+
if (!importOperationId) {
|
195
|
+
// Skip further processing if no import operation is found
|
195
196
|
continue;
|
196
197
|
}
|
197
198
|
|