JSPM

  • Created
  • Published
  • Downloads 2686
  • Score
    100M100P100Q120558F
  • License GPLv3

Client-side mongo database with server sync over http

Package Exports

  • minimongo

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (minimongo) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Minimongo

A client-side MongoDB implementation which supports basic queries, including some geospatial ones.

Usage

Minimongo is designed to be used with browserify.

// Require minimongo
var minimongo = require("minimongo");

var LocalDb = minimongo.LocalDb;

// Create local db (in memory database with no backing)
db = new LocalDb();

// Add a collection to the database
db.addCollection("animals");

doc = { species: "dog", name: "Bingo" };

// Always use upsert for both inserts and modifies
db.animals.upsert(doc, function() {
    // Success:

    // Query dog (with no query options beyond a selector)
    db.animals.findOne({ species:"dog" }, {}, function(res) {
        console.log("Dog's name is: " + res.name);
    });
});

HybridDb

Queries the local database first and then returns remote data if different than local version.

This approach allows fast responses but with subsequent correction if the server has differing information.