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

uj-mongoose-fixtures

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

uj-mongoose-fixtures

Mongoose Data Fixtures

  • 0.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

mongoose-fixtures

Build Status

This library aims to provide a simple way to manage and execute the loading of data fixtures for the mongoose. Here is a simple example of a fixture:

// fixtures/user-fixture.js
module.exports = function(conn, references) {
	User = conn.model('User');
	var user = new User({...})
	return user.save();
};

A fixture is any callback which returns a promise. The promise should be resolved when all the fixtures data are loaded to the database.

Then you need to add fixtures to a loader instance:

var loader = require('mongoose-fixtures').loader();
loader.load(require('fixtures/user-fixture'));

You can load a set of fixtures from a directory as well:

var path = require('path');

loader.loadFromDirectory(path.resolve(__dirname, './fixtures'));

Then you can execute the fixtures:

var mongoose = require('mongoose'),
  executor = require('mongoose-fixtures').executor(mongoose);
  
executor.execute(loader);

Running the tests

  • clone the repo and go to the root directory of the repo
  • npm install
  • npm test

Keywords

FAQs

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