title: How can I use MongoLab Api with Breeze.js?
body: <p>How do I connect MongoDB using MongoLab Api to Breeze.js with angular.js  Can anyone help with wiring up the setup. Has anyone tried this setup?</p>
  
  <pre><code>https://api.mongolab.com/api/1/databases/my-db/collections/my-coll?apiKey=myAPIKey
  </code></pre>
  
  <p>Here's datacontext.js from breeze site. 
  Here's the plunkr <a href="http://plnkr.co/edit/upp7wB?p=preview" rel="nofollow">http://plnkr.co/edit/upp7wB?p=preview</a></p>
  
  <pre><code>app.factory('datacontext',['$http','logger',  function($http, logger) {
    var log = logger.log;
  
    log("Creating datacontext");
    configureBreeze();
  
    var useLocalHost = false;
    var host=useLocalHost ? "http://localhost:63428" : "http://sampleservice.breezejs.com";
    var serviceName = host+"/api/todos";
  
    var manager = new breeze.EntityManager(serviceName);
  
    plunkerHelpers.isCorsCapable();
    var datacontext = {
      getAllTodos: getAllTodos,
      reset: reset
    };
    return datacontext;
  
    /***  supporting functions ***/  
  
    function getAllTodos() {
      var query = breeze.EntityQuery.from("Todos");    
      log("Getting Todos");
      return manager.executeQuery(query).then(success);
  
      function success(data) {
          log("Retrieved " + data.results.length);
          return data.results;
      }
    }
  
    function reset() {
      manager.clear(); 
      var deferred = Q.defer();
      $http.post(serviceName + '/reset')
       .then(resetSuccess, resetFail);
      return deferred.promise;
  
      function resetSuccess() {
        log("Database reset");
        deferred.resolve();
      }
      function resetFail() {
        log("Database reset failed");
        deferred.reject(new Error("Database reset failed"));
      }
    }
  
    function configureBreeze() {
      // configure to use the model library for Angular
      breeze.config.initializeAdapterInstance("modelLibrary", "backingStore", true);
      // configure to use camelCase
      breeze.NamingConvention.camelCase.setAsDefault();
    }
  }]);
  </code></pre>
  
  <p>source Files.
  <a href="http://www.breezejs.com/samples/todo-angular" rel="nofollow">http://www.breezejs.com/samples/todo-angular</a></p>
  
  <p><a href="https://support.mongolab.com/entries/20433053-REST-API-for-MongoDB" rel="nofollow">https://support.mongolab.com/entries/20433053-REST-API-for-MongoDB</a></p>