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.

129 lines (108 loc) 3.33 kB
# yaml-language-server: $schema=../.yaml_schemas/import-config.schema.json # Categories Import Configuration with Hierarchy Support source: file: "importData/categories.json" basePath: "RECORDS" type: "json" target: collection: "Categories" type: "create" primaryKey: "category_id" createUsers: false mapping: attributes: # Core Fields - oldKey: "category_id" targetKey: "categoryId" converters: ["anyToString"] validation: - rule: "required" params: ["{categoryId}"] - oldKey: "name" targetKey: "name" converters: ["anyToString", "stringTrim"] validation: - rule: "required" params: ["{name}"] - rule: "minLength" params: ["{name}", "2"] - oldKey: "slug" targetKey: "slug" converters: ["anyToString", "stringToLowerCase", "stringTrim"] - oldKey: "description" targetKey: "description" converters: ["anyToString", "stringTrim"] validation: - rule: "maxLength" params: ["{description}", "500"] # Hierarchy - oldKey: "parent_id" targetKey: "parentId" converters: ["anyToString"] - oldKey: "level" targetKey: "level" converters: ["anyToNumber"] validation: - rule: "numeric" params: ["{level}"] - rule: "positive" params: ["{level}"] - oldKey: "sort_order" targetKey: "sortOrder" converters: ["anyToNumber"] # Visual & Branding - oldKey: "color_code" targetKey: "colorCode" converters: ["anyToString"] - oldKey: "icon" targetKey: "icon" converters: ["anyToString"] # Cover Image with URL Download - oldKey: "cover_image_url" targetKey: "coverImage" fileData: path: "{cover_image_url}" name: "{category_id}_cover" afterImport: - action: "createFileAndUpdateField" params: ["{dbId}", "{collId}", "{docId}", "coverImage", "{bucketId}", "{filePath}", "{fileName}"] # Status - oldKey: "is_active" targetKey: "isActive" converters: ["anyToBoolean"] - oldKey: "is_featured" targetKey: "isFeatured" converters: ["anyToBoolean"] # Statistics - oldKey: "post_count" targetKey: "postCount" converters: ["anyToNumber"] - oldKey: "total_post_count" targetKey: "totalPostCount" converters: ["anyToNumber"] # SEO - oldKey: "meta_title" targetKey: "metaTitle" converters: ["anyToString", "stringTrim"] validation: - rule: "maxLength" params: ["{metaTitle}", "60"] - oldKey: "meta_description" targetKey: "metaDescription" converters: ["anyToString", "stringTrim"] validation: - rule: "maxLength" params: ["{metaDescription}", "160"] - oldKey: "guidelines" targetKey: "guidelines" converters: ["anyToString", "stringTrim"] relationships: # Parent-Child Relationship Resolution - sourceField: "parent_id" targetField: "parentId" targetCollection: "Categories" options: batchSize: 50 skipValidation: false dryRun: false continueOnError: true