• Stars
    star
    112
  • Rank 312,240 (Top 7 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 13 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Fixture loader for NodeJS' Mongoose ODM. Check pow-mongodb-fixtures instead to load data straight to MongoDB, skipping Mongoose.

mongoose-fixtures

Simple fixture loader for Mongoose on NodeJS.

Fixtures can be in one file, or divided up into separate files for organisation (e.g. one file per model)

The fixture files must export objects which are keyed by the Mongoose model name, each containing the data for documents within that.

NOTE: Loading fixtures will clear the existing contents of a collection!

FOR EXAMPLE: With the file below, 3 documents will be inserted into the 'User' collection and 2 into the 'Business' collection:

//fixtures.js
exports.User = [
    { name: 'Gob' },
    { name: 'Buster' },
    { name: 'Steve Holt' }
];

exports.Business = [
    { name: 'The Banana Stand' },
    { name: 'Bluth Homes' }
];

You can also load fixtures as an object where each document is keyed, in case you want to reference another document:

//users.js
var ObjectId = require('mongodb').BSONNative.ObjectID;

exports.User = {
    user1: {
        _id: new ObjectId(),
        name: 'Michael'
    },
    user2: {
        _id: new ObjectId(),
        name: 'George Michael',
        father: exports.User.user1._id
    }
}

Usage

var fixtures = require('pow-mongoose-fixtures');

//Objects
fixtures.load({
    User: [
        { name: 'Maeby' },
        { name: 'George Michael' }
    ]
});

//Files
fixtures.load(__dirname + '/fixtures/users.js', callback);

//Directories (loads all files in the directory)
fixtures.load(__dirname + '/fixtures', callback);

Installation

npm install pow-mongoose-fixtures --save-dev

More Repositories

1

backbone-forms

Form framework for BackboneJS with nested forms, editable lists and validation
JavaScript
2,167
star
2

backbone-deep-model

Improved support for models with nested attributes.
JavaScript
648
star
3

backbone.bootstrap-modal

Bootstrap Modal wrapper for use with Backbone.
JavaScript
183
star
4

buildify

Builder for creating distributable JavaScript files from source. Concatenate, wrap, uglify.
JavaScript
123
star
5

pow-mongodb-fixtures

Easy JSON fixture loading for MongoDB. Makes managing relationships easier.
JavaScript
108
star
6

mongoose-taggable

Simple tagging plugin for Mongoose
JavaScript
23
star
7

nodeunit-httpclient

HTTP response testing for NodeUnit
JavaScript
16
star
8

mongoose-plugins

Plugins for NodeJS' Mongoose ODM: Slugger, Timestamper, Authenticator, Pointer (DBRefs), Validators
JavaScript
15
star
9

backbone.xview

Easy to use view manager for Backbone. Effortless nested views and templating.
JavaScript
10
star
10

pow-underscore

Underscore with mixins and path support
JavaScript
7
star
11

pow-mongoose-plugins

Plugins for Mongoose (NodeJS MongoDB ORM)
JavaScript
6
star
12

mocker

NodeJS mocking library
JavaScript
3
star
13

backbone.screenmanager

Manage mobile Backbone views with menus, overlays and transitions
JavaScript
3
star
14

pow-express-utils

Express utils
JavaScript
3
star
15

powActivatablePlugin

Symfony 1.4 plugin: Adds the Activatable Doctrine behavior which is useful for when you want to hide or 'switch off' certain records. For example, for moderation, approval etc. This adds an is_active column (can be renamed) and helper methods to the Table model class for modifying queries.
PHP
3
star
16

powJSONActions

A simple Symfony 1.4 plugin to make responding to JSON requests and debugging easier.
PHP
2
star
17

update-props

Updates a whitelist of an object's properties and returns changes, if any
JavaScript
1
star
18

heroku-utils

Utilities for apps running on Heroku
JavaScript
1
star
19

pow-mongoose-timestamps

Add created and updated timestamps to Mongoose models
JavaScript
1
star