# mongo-data-factory

> - [mongo-data-factory](#mongo-data-factory) - [Initialize Factory Seeder](#initialize-factory-seeder) - [Run your factory 🚀](#run-your-factory-)

Latest version **1.0.5** (published 2021-03-30) · ISC license · 0 weekly downloads

## Install

```sh
npm install mongo-data-factory
pnpm add mongo-data-factory
yarn add mongo-data-factory
bun add mongo-data-factory
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2021-03-30 |
| First published | 2021-03-30 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 4.4 KB |
| Known vulnerabilities | 0 (+3 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Joseph Makram |
| Maintainers | jojomak13 |

## Links

- npm: https://www.npmjs.com/package/mongo-data-factory
- Repository: https://github.com/jojomak13/mongo-data-factory
- Homepage: https://github.com/jojomak13/mongo-data-factory#readme
- Issues: https://github.com/jojomak13/mongo-data-factory/issues
- npm.io page: https://npm.io/package/mongo-data-factory

## Dependencies (2)

- [faker](https://npm.io/package/faker.md) ^5.5.1
- [mongoose](https://npm.io/package/mongoose.md) ^5.12.2

## Recent versions

- 1.0.5 (latest) — 2021-03-30
- 1.0.4 — 2021-03-30
- 1.0.3 — 2021-03-30
- 1.0.2 — 2021-03-30
- 1.0.1 — 2021-03-30
- 1.0.0 — 2021-03-30

## README

# mongo-data-factory

- [mongo-data-factory](#mongo-data-factory)
- [Initialize Factory Seeder](#initialize-factory-seeder)
- [Run your factory 🚀](#run-your-factory-)

# Initialize Factory Seeder

first you need to define your **collecetion** (table) schema
for this example i have a table called `Country`

```javascript
const countryFactory = Factory.define(Country, (faker: Faker.FakerStatic) => {
  return {
    name: faker.address.country(),
    code: faker.address.countryCode(),
    currency: faker.finance.currencyCode(),
    timezone: faker.address.timeZone(),
  };
});
```

# Run your factory 🚀

After initialize it you just run one line of code

you could pass as argument your number of records you want to create
by default it creates only only **one** record

```javascript
countryFactory.create(); // will create one reacord

countryFactory.create(10); // will create 10 reacords

countryFactory.create().then(() => {
  // you could run some logic here to 😀
});
```

---
_Source: https://npm.io/package/mongo-data-factory · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
