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
source:
file: "importData/categories.json"
basePath: "RECORDS"
type: "json"
target:
collection: "Categories"
type: "create"
primaryKey: "category_id"
createUsers: false
mapping:
attributes:
- 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"]
- 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"]
- oldKey: "color_code"
targetKey: "colorCode"
converters: ["anyToString"]
- oldKey: "icon"
targetKey: "icon"
converters: ["anyToString"]
- 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}"]
- oldKey: "is_active"
targetKey: "isActive"
converters: ["anyToBoolean"]
- oldKey: "is_featured"
targetKey: "isFeatured"
converters: ["anyToBoolean"]
- oldKey: "post_count"
targetKey: "postCount"
converters: ["anyToNumber"]
- oldKey: "total_post_count"
targetKey: "totalPostCount"
converters: ["anyToNumber"]
- 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:
- sourceField: "parent_id"
targetField: "parentId"
targetCollection: "Categories"
options:
batchSize: 50
skipValidation: false
dryRun: false
continueOnError: true