UNPKG

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.

130 lines (110 loc) 3.29 kB
# yaml-language-server: $schema=../.yaml_schemas/import-config.schema.json # User Import Configuration with Avatar File Handling source: file: "importData/users.json" basePath: "RECORDS" type: "json" target: collection: "Users" type: "create" primaryKey: "user_id" createUsers: true mapping: attributes: # Core Identity Fields - oldKey: "user_id" targetKey: "userId" converters: ["anyToString"] validation: - rule: "required" params: ["{userId}"] - oldKey: "name" targetKey: "name" converters: ["anyToString", "stringTrim"] validation: - rule: "required" params: ["{name}"] - rule: "minLength" params: ["{name}", "2"] - oldKey: "email" targetKey: "email" converters: ["anyToString", "stringToLowerCase", "stringTrim"] validation: - rule: "required" params: ["{email}"] - rule: "email" params: ["{email}"] - oldKey: "username" targetKey: "username" converters: ["anyToString", "stringToLowerCase", "stringTrim"] validation: - rule: "minLength" params: ["{username}", "3"] # Avatar File Handling with URL Download - oldKey: "avatar_url" targetKey: "avatar" fileData: path: "{avatar_url}" name: "{user_id}_avatar" afterImport: - action: "createFileAndUpdateField" params: ["{dbId}", "{collId}", "{docId}", "avatar", "{bucketId}", "{filePath}", "{fileName}"] # Contact Information - oldKey: "phone" targetKey: "phone" converters: ["anyToString"] validation: - rule: "phone" params: ["{phone}"] - oldKey: "bio" targetKey: "bio" converters: ["anyToString", "stringTrim"] validation: - rule: "maxLength" params: ["{bio}", "500"] # Dates - oldKey: "date_of_birth" targetKey: "dateOfBirth" converters: ["anyToDate"] - oldKey: "last_login_at" targetKey: "lastLoginAt" converters: ["anyToDate"] # Location - oldKey: "location" targetKey: "location" converters: ["anyToString", "stringTrim"] # User Management - oldKey: "role" targetKey: "role" converters: ["anyToString", "stringToLowerCase"] validation: - rule: "required" params: ["{role}"] - oldKey: "is_active" targetKey: "isActive" converters: ["anyToBoolean"] - oldKey: "is_verified" targetKey: "isVerified" converters: ["anyToBoolean"] # Statistics - oldKey: "profile_views" targetKey: "profileViews" converters: ["anyToNumber"] validation: - rule: "numeric" params: ["{profileViews}"] - rule: "positive" params: ["{profileViews}"] # JSON Fields - oldKey: "social_links" targetKey: "socialLinks" converters: ["anyToString"] - oldKey: "preferences" targetKey: "preferences" converters: ["anyToString"] relationships: [] options: batchSize: 25 skipValidation: false dryRun: false continueOnError: true