appwrite-utils-cli
Version:
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.
22 lines (21 loc) • 806 B
JavaScript
import { tryAwaitWithRetry } from "appwrite-utils";
import { ulid } from "ulidx";
export const logOperation = async (db, dbId, operationDetails, operationId) => {
try {
let operation;
if (operationId) {
// Update existing operation log
operation = await tryAwaitWithRetry(async () => await db.updateDocument("migrations", "currentOperations", operationId, operationDetails));
}
else {
// Create new operation log
operation = await db.createDocument("migrations", "currentOperations", ulid(), operationDetails);
}
console.log(`Operation logged: ${operation.$id}`);
return operation;
}
catch (error) {
console.error(`Error logging operation: ${error}`);
throw error;
}
};