Table/Collection schema
- Schema is generated as per the collection data.
 
Supported schema properties
- __type
 - validations
 - conversions
 - isPrimaryKey
 - isAutoIncrementByAM
 - isAutoIncrementByDB
 - collection/table
 - column
 - database
 - instance
 
__type
API Maker schema supports the below data types.
- boolean
 - date
 - file
 - files
 - number
 - objectId
 - string
 
validations
Supported validations properties
- required
 - max
 - min
 - minLength
 - maxLength
 - unique
 - validatorFun
 - enum [v1.11+]
 
required
- It has boolean value true/false.
 - If 'required: true' is not present in validations, by default, it's 'required: false'.
 
- It has been a boolean value true/false.
 - If it has true value then it's validate field value for email.
 - If 'email: true' is not present in validations, by default, it's 'email: false'.
 
min & max
- min and max validations are applied on the number column type.
 
minLength & maxLength
- minLength and maxLength validations are applied to the string column type.
 
unique
- If any field has 'unique: true' validation it can not save with duplicate value.
 
- Request payload has three objects in which the last object phone number is not unique. All the other objects were not saved too in both 'save single | multiple' and 'master save | update' APIs.
 
Request payload
validatorFun
- Write custom function code for more validations on a particular field.
 - We have field value and the full object of the body.
 - validatorFun will be executed last. So, if you modify data in those functions that are invalid, and try to save/update, it will pass through.
 
enum [v1.11+]
- Conversion will run before validation
 - If value is present, it should be from given array.
 - Validation will not be performed when enum array is empty.
 - Generate Data will take values from enum instead of random values. It will work in swagger docs and all the relevant APIs.
 
conversions
- To convert any payload column value use 'conversions'.
 - We need to write the conversion function here as 'conversionFun'.
 
The 'conversions' supports below properties.
- trimStart: boolean - To remove space from the start of the value.
 - trimEnd: boolean - To remove space from the end of the value.
 - trim: boolean - To remove space from the start and end of the value.
 - toLowerCase: boolean - Convert all characters of the value to lowercase.
 - toUpperCase: boolean - Convert all characters of the value to upper case.
 - conversionFun: function - Write a custom function to change the given value. (v1.11.0+) It will be executed even if value is not present in payload.
 - encryption: boolean - If it's true it will encrypt the value and save.
 - hashing: boolean - It will create a hash of the value and save.
 - defaults [v1.11+]: It is used to set default values.
 
isPrimaryKey
- The database table has the column as the primary key then it will add 'isPrimaryKey: true' in the schema.
 
isAutoIncrementByAM
- Add 'isAutoIncrementByAM: true' if we make any column auto increment. It makes a field auto increment from the API Maker not from the database.
 
isAutoIncrementByDB
- Add 'isAutoIncrementByDB: true' if the column is an auto increment from the database side.
 
collection/table
- To save, get and update nested deep data from any collection/table, use 'collection or table'.
 - You must have to provide 'column'.
 
database
- To save, get and update nested deep data from any database's collection, use 'database'.
 - If 'database' is not there API Maker takes the same database in which the schema right now you are editing.
 
instance
- To save, get and update nested deep data from any instance, any database, and any collection, use 'instance'.
 - If 'instance' is not there API Maker takes the same instance in which the schema right now you are editing.
 
defaultFun
- defaultValue has higher priority compare to defaultFun.
 - If defaultValue is not present, system will execution this function and returned value will be set.
 - While saving new record, if value is not provided then this function will be executed to generate default value.