Coder Social home page Coder Social logo

mockgoose's Introduction

Build Status

Please Share on Twitter if you like #mockgoose

##What is Mockgoose?

Mockgoose is a simplified in memory database that allows you to perform actions on Mongoose Models without having a running instance of MongoDB.

The main purpose of Mockgoose as you may have guessed from the name is to allow you to mock out your mongoose database during testing so that you do not have to spin up a new database for every test and teardown that same database afterwards.

##Install To install the latest official version, use NPM:

npm install mockgoose --save-dev

To run the tests and see what is supported by Mockgoose navigate to the Mockgoose folder and run the test suite

npm test

##Usage You simply require Mongoose and Mockgoose and wrap Mongoose with Mockgoose.

var mongoose = require('mongoose');
var mockgoose = require('mockgoose');

mockgoose(mongoose);

Once Mongoose has been wrapped by Mockgoose all calls to connect() and createConnection() will be intercepted by Mockgoose so that no MongoDB instance is created.

###Options mongoose required Instance of mongoose.

throwError optional Boolean true/false to throw errors on connection defaults to false.

###Connection Events Dispatches some but not all of the events supported by Mockgoose http://mongoosejs.com/docs/api.html#connection_Connection

Supported Events

connecting
connected
open
error

Currently supported model operations are.

save();
create();
remove();
count();
find();
findById();
findByIdAndRemove();
findByIdAndUpdate();
findOne();
findOneAndRemove();
findOneAndUpdate();
Update();

##Operators

##Options

  • multi : 0/1 defaults to 0
  • upsert : true/false defaults to false
  • sort : one level of sorting for find operations {sort: {name:1}}
  • skip
  • limit

##Validators Mockgoose includes support for validators and the unique field key.

Mockgoose comes with a reset() method that allows you to reset the Mockgoose database simply call

mockgoose.reset() 

to delete all the collections and models in the database or call

mockgoose.reset('schema name')*

to delete all the associated models for a schema. *schema names are case sensitive

mockgoose's People

Contributors

feleir avatar fodor0205 avatar krisb avatar mccormicka avatar mctep avatar nukulb avatar qraynaud avatar seansullivan avatar twistedstream avatar wavded avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.