Typescript
You can export the data generated by schemas or any type of data to typescript format
const userSchema = chaca.schema({
id: schemas.id.uuid(),
username: schemas.internet.userName(),
image: { type: schemas.image.people(), posibleNull: 50 },
posts: {
type: schemas.id.uuid(),
isArray: {
min: 1,
max: 5,
},
},
})
await userSchema.generateAndExport({
filaName: 'data',
format: 'typescript',
location: 'folder',
})
For example, if we have this schema, we generate 5 documents and export them in typescript format, we will obtain the following result
interface Objectc2f4gg01e4056a0a75763438 {
id: string
username: string
image: string | null
posts: Array<string>
}
const data: Array<Objectc2f4gg01e4056a0a75763438> = [
{
id: '03a342dc-5e0e-4d3c-a208-662741868b92',
username: 'Liam.',
image: 'https://pixabay.com/get/g77f181226c027a069cd3819a2960a9791dbd2805472d7d73c986672f2b10f483b5862b3889c0a5fb2d5c523622115d8178cfd1d30cdd821957ce4413c1c8554f_1280.jpg',
posts: [
'2c1ee533-64b0-493b-9c27-7177347c52be',
'761c51c8-7957-4a13-8572-22eedd8d9706',
],
},
{
id: 'dbe3cbb7-7bab-48e9-b79d-e160250066c1',
username: 'Ella.',
image: null,
posts: [
'0dcc7d5d-08bc-4479-ac36-347cc3d85468',
'ec0eb929-2aa2-4537-ab12-2bb3273a9619',
'2beb5935-3be1-4c7c-b872-d166125821c0',
'110dc443-6a91-4549-96c0-c5e2dbe56cd2',
],
},
{
id: '4d1ad70b-563d-40b1-9c58-8d51db248ec8',
username: 'Stella077',
image: null,
posts: [
'01d823a6-b0ad-4dd3-b037-794748bdd1e3',
'41c99814-964c-47a9-93cd-481a6edb5b6e',
],
},
{
id: '92be70e6-1ca2-493e-8bcd-951c125ebcc3',
username: 'Nova454',
image: 'https://images.unsplash.com/photo-1464746133101-a2c3f88e0dd9?crop=entropy&cs=tinysrgb&fm=jpg&ixid=MnwzNTM2NjZ8MHwxfHNlYXJjaHw0MXx8cGVvcGxlfGVufDB8fHx8MTY2Njk3MDgzMw&ixlib=rb-4.0.3&q=80',
posts: [
'65525775-ae08-4210-a58a-0ce084364187',
'dcc8ecae-0083-4d2d-8693-37b8499eba32',
],
},
{
id: '0ae2788d-c334-408d-b71a-79a540c2b82d',
username: 'Christopher950',
image: null,
posts: [
'96ac2aa8-7d68-47d9-a41b-12bb2341e38c',
'e4189b85-d577-4e4c-bad0-d239b4b27c49',
'bb1636d8-6d42-4976-9aac-3824507abb9b',
'48d372e1-00bd-4261-9a35-54dd21ed330c',
],
},
]