National Preventative Mechanism
    Wondering what’s next for npm?Check out our public roadmap! »

    mongosync

    1.1.3 • Public • Published

    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

    Install

    npm i mongosync

    DownloadsWeekly Downloads

    2

    Version

    1.1.3

    License

    MIT

    Last publish

    Collaborators

    • avatar