Socket
Book a DemoInstallSign in
Socket

mongo-restore

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongo-restore

test

latest
Source
npmnpm
Version
0.1.3
Version published
Maintainers
1
Created
Source

mongo-restore

Simple module for populate data to mongo collection from js/json

Useful things

It's very important to write code faster and not spend a lot of time for create and manage any fixture for checking if you code work well... This simple module get you simple and fast method for populating your mongo db collection on the fly.

Install

I sure, it is normal to use dev dependency for that:

npm install mongo-restore -D

Usage

Create some directory in you project. Place any files with data there. Run mongo-restore just tell him there is it have to looking for you fixtures and how you test base is called:

|-project
|--tests
|---fixtures
|----myTestCollection.js  //  (file inners: module.exports = {a: 1, b: 2})
|----myTestColl2.json     // You also can use json type
const restore = require('mongo-restore');
// using with promises
restore({path: '/tests/fixtures', dropDb: true})
  .then(res => console.log('test db restored'))
  .catch(err => console.error(err))

// using callback
restore({path: '/tests/fixtures', dropDb: true}, (err, res) => {
  if (err) console.error(err); return;
  console.log('test db restored')
})

This code remove all data from mongo test db and create two collections with same names as you fixture files are called (First one: myTextCollection; second one: myTextColl2)

Keywords

restore

FAQs

Package last updated on 24 Apr 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