# plus.garden.fixtures-mongo

> mongo fixtures loader for plus.garden

Latest version **0.0.7** (published 2016-07-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install plus.garden.fixtures-mongo
pnpm add plus.garden.fixtures-mongo
yarn add plus.garden.fixtures-mongo
bun add plus.garden.fixtures-mongo
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.7 |
| Published | 2016-07-06 |
| First published | 2014-10-31 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Vladimir Polyakov |
| Maintainers | skadabr |
| Keywords | mongo, fixtures |

## Links

- npm: https://www.npmjs.com/package/plus.garden.fixtures-mongo
- Repository: https://github.com/linkshare/plus.garden.fixtures-mongo
- Homepage: https://github.com/linkshare/plus.garden.fixtures-mongo#readme
- Issues: https://github.com/linkshare/plus.garden.fixtures-mongo/issues
- npm.io page: https://npm.io/package/plus.garden.fixtures-mongo

## Dependencies (2)

- [bson](https://npm.io/package/bson.md) 0.4.23
- [pow-mongodb-fixtures](https://npm.io/package/pow-mongodb-fixtures.md) 0.12.0

## Alternatives

- [angular-pipes](https://npm.io/package/angular-pipes.md) — 5.6K weekly downloads
- [@ng-web-apis/midi](https://npm.io/package/@ng-web-apis/midi.md) — 2.6K weekly downloads
- [happn-3](https://npm.io/package/happn-3.md) — 1.6K weekly downloads
- [@opensip-cli/lang-go](https://npm.io/package/@opensip-cli/lang-go.md) — 1.2K weekly downloads
- [mongoose-typescript](https://npm.io/package/mongoose-typescript.md) — 85 weekly downloads

## Recent versions

- 0.0.7 (latest) — 2016-07-06
- 0.0.6 — 2016-05-12
- 0.0.5 — 2015-07-29
- 0.0.4 — 2015-07-29
- 0.0.3 — 2015-07-27
- 0.0.2 — 2014-10-31
- 0.0.1 — 2014-10-31

## README

plus.garden.fixtures-mongo
=======================

mongo fixtures loader for plus.garden

this module uses https://github.com/powmedia/pow-mongodb-fixtures


Install
===========================

Install npm package
```
npm i plus.garden.fixtures-mongo --save
```

Add service to garden container
```
container.register('MongoFixtureLoaderModule', require('plus.garden.fixtures-mongo'));
```

Add config section to garden config

```javascript
"fixtures-mongo": {

    "uri": "mongodb://user:password@localhost:27017/dbname",

    "fixtures": "fixtures/mongo"
}
```

Create directory for storing fixtures
```
mkdir -p fixtures/mongo
```

Usage
=========================================

Creating fixtures files:

FOR EXAMPLE:
With the file below, 3 documents will be inserted into the 'users' collection and 2 into the 'businesses' collection:
```javascript
    //fixtures.js
    exports.users = [
        { name: 'Gob' },
        { name: 'Buster' },
        { name: 'Steve Holt' }
    ];

    exports.businesses = [
        { name: 'The Banana Stand' },
        { name: 'Bluth Homes' }
    ];
```

You can also load fixtures as an object where each document is keyed, in case you want to reference another document. This example uses the included `createObjectId` helper:
*Note: install pow-mongodb-fixtures in project `npm install pow-mongodb-fixtures --save` to use `createObjectId` helper*
```javascript
    //users.js
    var id = require('pow-mongodb-fixtures').createObjectId;

    var users = exports.users = {
        user1: {
            _id: id(),
            name: 'Michael'
        },
        user2: {
            _id: id(),
            name: 'George Michael',
            father: users.user1._id
        },
        user3: {
            _id: id('4ed2b809d7446b9a0e000014'),
            name: 'Tobias'
        }
    }
```

commands:
```
./garden.js fixtures.load
./garden.js fixtures.drop
```

`fixture.load` runs `fixtures.drop` automatically

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