Welcome to Chaca, a powerful Nodejs library that revolutionizes mock data generation for testing and development processes. With Chaca, you can effortlessly generate realistic and diverse fake data to simulate different scenarios for your application.
npm install chaca
Visit our website to read the documentation. Chaca Docs
import { chaca, modules } from "chaca";
const movieSchema = chaca.schema({
id: chaca.key(() => modules.id.uuid()),
authors: {
type: () => modules.person.fullName({ language: "es" }),
isArray: { min: 1, max: 3 },
},
image: () => modules.image.film(),
likes: () => modules.datatype.int({ min: 0, max: 500000 }),
category: chaca.enum(["Horror", "War", "History", "Comedy"]),
adultMovie: ({ currentFields: docFields }) => {
return (
docFields.category === "Horror" ||
docFields.category === "War" ||
docFields.category === "Action"
);
},
});
// Generate 20 objects with the defined schema
const docs = movieSchema.array(20);
/*
[
{
id: "4136cd0b-d90b-4af7-b485-5d1ded8db252",
authors: ["Olivia Gonzalez Gomez", "Santiago Torres Gil"],
image: "https://loremflickr.com/480/480/film",
likes: 21456,
category: "Horror",
adultMovie: true,
},
...rest, // 19 more documents
];
*/
// Generate 20 objects and export them in a json file
await movieSchema.export(20, {
filename: "movies",
format: "json",
location: "./folder",
});
See CLI guide
If you don't want to use our npm package you can use our REST API to create your mock data
Detailed changes for each release are documented in the CHANGELOG.md.
The Chaca project welcomes all constructive contributions. Contributions take many forms, from code for bug fixes and enhancements, to additions and fixes to documentation, additional tests, triaging incoming pull requests and issues, and more!. See CONTRIBUTING.md
MIT