Socket
Book a DemoInstallSign in
Socket

plus.garden.fixtures-mongo

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

plus.garden.fixtures-mongo

mongo fixtures loader for plus.garden

0.0.7
latest
Source
npmnpm
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

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

"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:

    //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

    //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

Keywords

mongo

FAQs

Package last updated on 06 Jul 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.