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
source:
file: "importData/users.json"
basePath: "RECORDS"
type: "json"
target:
collection: "Users"
type: "create"
primaryKey: "user_id"
createUsers: true
mapping:
attributes:
- 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"]
- oldKey: "avatar_url"
targetKey: "avatar"
fileData:
path: "{avatar_url}"
name: "{user_id}_avatar"
afterImport:
- action: "createFileAndUpdateField"
params: ["{dbId}", "{collId}", "{docId}", "avatar", "{bucketId}", "{filePath}", "{fileName}"]
- oldKey: "phone"
targetKey: "phone"
converters: ["anyToString"]
validation:
- rule: "phone"
params: ["{phone}"]
- oldKey: "bio"
targetKey: "bio"
converters: ["anyToString", "stringTrim"]
validation:
- rule: "maxLength"
params: ["{bio}", "500"]
- oldKey: "date_of_birth"
targetKey: "dateOfBirth"
converters: ["anyToDate"]
- oldKey: "last_login_at"
targetKey: "lastLoginAt"
converters: ["anyToDate"]
- oldKey: "location"
targetKey: "location"
converters: ["anyToString", "stringTrim"]
- 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"]
- oldKey: "profile_views"
targetKey: "profileViews"
converters: ["anyToNumber"]
validation:
- rule: "numeric"
params: ["{profileViews}"]
- rule: "positive"
params: ["{profileViews}"]
- oldKey: "social_links"
targetKey: "socialLinks"
converters: ["anyToString"]
- oldKey: "preferences"
targetKey: "preferences"
converters: ["anyToString"]
relationships: []
options:
batchSize: 25
skipValidation: false
dryRun: false
continueOnError: true