fongus
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

Fongus

An npm package to generate dummy documents for your mongodb project with Mongoose or MongoDB driver

For more info on how to use the faker object check out their docs

For Mongoose

import { swamp, faker } from 'fongus'
import mongoose from 'mongoose'

const Schema = mongoose.Schema

const User = new Schema({
    name: String,
    email: String,
    adress: {
        zip: String,
        street: String,
    },
    colors: [String],
})

await swamp({
    count: 10,
    fields: {
        name: faker.name.firstName,
        email: faker.internet.email,
        address: {
            zip: faker.address.zipCode,
            street: faker.address.street,
        },
        colors: [faker.color.human, faker.color.human],
    },
    path: User,
})

For MongoDB

import { swamp, faker } from 'fongus'
import { MongoClient } from 'mongodb'

const url = 'mongodb://localhost:27017'
const client = new MongoClient(url)

await swamp({
    count: 10,
    fields: {
        name: faker.name.firstName,
        email: faker.internet.email,
        address: {
            zip: faker.address.zipCode,
            street: faker.address.street,
        },
        colors: [faker.color.human, faker.color.human],
    },
    path: client.db('myProject').collection('users'),
})

/fongus/

    Package Sidebar

    Install

    npm i fongus

    Weekly Downloads

    1

    Version

    0.1.1

    License

    MIT

    Unpacked Size

    14.8 kB

    Total Files

    49

    Last publish

    Collaborators

    • immatheus