Socket
Socket
Sign inDemoInstall

mongo-resetter

Package Overview
Dependencies
23
Maintainers
9
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    mongo-resetter

Interface to reset mongo


Version published
Weekly downloads
2
Maintainers
9
Install size
1.28 MB
Created
Weekly downloads
 

Readme

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

Last updated on 28 Dec 2015

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc