Skip to content

A Backbone.Sync replacement for persisting data on the backend using MongoJS

License

Notifications You must be signed in to change notification settings

CondeNast/MongoSync

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

MongoSync

A drop-in Backbone.Sync replacement for persisting data on the backend.

More info

Installing

npm install mongosync

or

bower install mongosync

Interface

MongoSync returns a function which then returns a context-aware Backbone model. It's wrapped in a function so that the sync method can be given the correct db location and collection to use.

Using with RequireJS

It will detect if you're in an AMD situation and provide the appropriate define for RequireJS. You will also need amdefine in your project.

Example:

if(typeof define !== 'function'){
    define = require('amdefine')(module);
}

define(function(require){
    var SharedModel = require('mongosync')('localhost', 'test');

    var MyModel = SharedModel.extend({});

    return MyModel;
});

Using in CommonJS (including Browserify)

var SharedModel = require('mongosync')('localhost', 'test');

var MyModel = SharedModel.extend({});

module.exports = MyModel;

Browser Global (not recommended)

<!-- script tags for backbone and underscore appear here -->
<script src="bower_components/mongosync/mongosync.js"></script>

Then in your code:

var MyModel = SharedModel().extend({});

Development

To install the dependencies:

npm install

Uses grunt to handle development tasks. All grunt tasks are available via npm run using a locally installed copy of grunt-cli.

Testing

npm test to run unit tests.

You will need a mongodb server running somewhere to run the tests...

License

MongoSync is provided under the terms of the MIT License

About

A Backbone.Sync replacement for persisting data on the backend using MongoJS

Resources

License

Stars

Watchers

Forks

Packages

No packages published