angularjs-Zza-BMEAN icon indicating copy to clipboard operation
angularjs-Zza-BMEAN copied to clipboard

Deployment using MongoHQ

Open 6gsaifulislam opened this issue 10 years ago • 2 comments

Sorry to be a pain, but after a whole afternoon of trying to get the stack linked to my MongoHQ database - I seen to be going round and round in circles. Would it be possible to post your version of the "remote-database.js" file (with dummy file, user and passwords of course) so that I can see where I am going wrong!

6gsaifulislam avatar May 30 '14 17:05 6gsaifulislam

breeze-routes.js

/**
 * Adds Breeze operation routes to the express() application via 'configureRoutes'
 */
module.exports = {
    configure: configureRoutes
};

var bmongo   = require('breeze-mongodb')
  , database = require('./remote-database' );

remote-database.js

/*
 * database service with an 'open' method that
 * creates a new MongoDb instance for the zza database
 * and opens it with optional post-open handler
 */
module.exports = {
    open: open
};

var mongodb = require('mongodb');

function open(openHandler ) {

    var dbName = 'app24796411'
      , host = 'oceanic.mongohq.com'
      , port = 10047;

    var dbServer = new mongodb.Server(host, port, { auto_reconnect: true});

    var db = new mongodb.Db(dbName, dbServer, {
        strict:true,
        w: 1,
        safe: true
    });

    var noop = function() { ; };

    db.open(function( error ){
        if ( !error )
        {
            db.authenticate("demo","breeze",noop);
            if ( openHandler != null) openHandler();
        }
    });

    return db;
}

ThomasBurleson avatar May 30 '14 17:05 ThomasBurleson

Many thanks - it was the authentication bit I messed up.

6gsaifulislam avatar May 30 '14 17:05 6gsaifulislam