Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mongo-resetter

Package Overview
Dependencies
Maintainers
9
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongo-resetter

Interface to reset mongo

  • 1.0.0
  • latest
  • npm
  • Socket score

Version published
Maintainers
9
Created
Source

mongo-resetter

Server/Client for resetting mongo instance running in a docker container.

Server

The server loads a fixture folder into a staging mongo database. Any client can then specify which local mongodb to load the fixtures into via an HTTP interface.

var MY_FIXTURE_PATH="/fixtures";
var MY_PORT = 8010;

var ResetterServer = require("mongo-resetter").Server;
var server = new ResetterServer();
server.listen(MY_PORT);

You can also specify a default fixture path when creating the server. The client will then not need to specify which fixtures to load.

var MY_FIXTURE_PATH="/fixtures";
var MY_PORT = 8010;

var ResetterServer = require("mongo-resetter").Server;
var server = new ResetterServer(MY_FIXTURE_PATH);
server.listen(MY_PORT);

Client

Any client can reset mongo fixtures via HTTP.

Clients first specify a set of fixture to load into a staging database

curl -X POST localhost:8010 -d '{ \
 "action": "LOAD", \
 "fixturePath": "/path/to/fixtures"
}'

Each subsequent reset action loads those fixtures into the specified database:
```bash
curl -X POST localhost:8010 -d '{ \
 "action": "RESET", \
 "db": "testing-database" \
}'

Http status 200 is returned if successful.

You can also do the above via the mongo-resetter client

var ResetterClient = require("mongo-resetter").Client;
var resetter = new ResetterClient("localhost", 8010);

//first load a fixture set into the resetter
resetter.loadFixtures("/path/to/fixtures", function(err) {
  if(err) {
    return console.error(err);
  }
  console.log("Successfully loaded fixtures");

  //now we can reset those fixtures into the testing-database
  resetter.resetFixtures("testing-database", function(err) {
    if(err) {
      return console.error(err)
    }
    console.log("Successfully reset fixtures");
  });
});

FAQs

Package last updated on 28 Dec 2015

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc