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


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

More info

npm install mongosync


bower install mongosync

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.

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.


if(typeof define !== 'function'){
    define = require('amdefine')(module);
    var SharedModel = require('mongosync')('localhost', 'test');
    var MyModel = SharedModel.extend({});
    return MyModel;
var SharedModel = require('mongosync')('localhost', 'test');
var MyModel = SharedModel.extend({});
module.exports = MyModel;
<!-- script tags for backbone and underscore appear here -->
<script src="bower_components/mongosync/mongosync.js"></script>

Then in your code:

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

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.

npm test to run unit tests.

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

MongoSync is provided under the terms of the MIT License