/ngMongo

An angular and node module for connecting to mongo

Primary LanguageJavaScriptMIT LicenseMIT

ngMongo

An angular and node module for connecting to mongo.

ngMongo gives developers an easy way to bind $scope variables to mongodb queries.

Check out the documentation here

Check out how it all works here


Node.js Module

###Simple setup:

var express = require('express')
, app = express()
, http = require('http')
, server = http.createServer(app)
, io = require('socket.io').listen(server)
, ngMongo = require('ngmongo')(io,app);

var db = ngMongo.db('mydb');
server.listen(80);

###Key features

  • Validation
  • Before documents are updated
  • After docuemts are updated
  • Before fields are updated
  • After fields are updated
  • Security
  • Roles based
  • User based
  • Public functions
  • Security
  • Angular promises

Server Side Docs


Angular Module

###Simple setup:

link scripts:

 <script src="/socket.io/socket.io.js"></script>
 <script src="/ngMongo/ngMongo.js"></script>

config angular:

var myApp = angular.module('myApp', ['ngMongo'])
.config(["$SocketsIoProvider", function($SocketsIo) {
    $SocketsIo.url('http://localhost');
}]);

bind to query:

myApp.controller('testController', function ($scope, $mongo) {
   $scope.boundArray = $mongo.query('mycollection').$find({ created: 'me' }).$toArray();
   $scope.saveItem = function(item){
      item.$save();
   };
});

"boundArray" will now update every time someone saves or updates a document in "mycollection" with a "created" field that equals "me"

###Key features

  • Realtime auto syncing query
  • Extendable documents object
  • Closely mirrored mongo functions
  • Chainable functions
  • Server functions via promises
  • ...

Client Side Docs