Mockup tool to feed a database with fake random values
- The fake value is generated according to the field label property.
- A few common fields are recognized automatically
- If the label is undefined or not recognized, it tries to look at the field type property instead (text, number, date)
Recognized field labels are:
- name
- first name
- last name
- full name
- company name
- department
- phone
- address
- address 1
- address 2
- zip code
- city
- country
- title
- description
- priority
- status
The fake values are generated one field at a time, so, to feed a complete record, you must loop over its list of fields.
const userRecord = {}
userModel.getFields().forEach(field => userRecord[field.id] = kiss.db.faker(field))
Parameters:
| Name | Type | Description |
|---|---|---|
field |
object
|
string
|
An object defining a label and a type | A simple string for the label ("First name") or the type ("number") |
Example
kiss.db.faker({label: "First name"}) can return "Julia"
kiss.db.faker("First name") can return "Julia"
kiss.db.faker({label: "Full name"}) can return "Julia Giordini"
kiss.db.faker({label: "Amount", type: "number"}) can return 123
kiss.db.faker({label: "Workload", type: "float", min: 0, max: 100, precision: 2}) can return 42.42
kiss.db.faker({label: "Invoice date", type: "date", year: 2020}) can return "2020-05-27"
kiss.db.faker("date") can return "1984-05-31"
kiss.db.faker("priority") can return "high"
kiss.db.faker("status") can return "in progress"