SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Dec 2012
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Chapter 1- connecting with Mangolab:

    While following chapter 1 example code, connect to mongolab, I am getting the error message: 'database names cannot contain the character '.' Here is my code:

    // .............................................................
    var mongoose = require('mongoose');
    var Schema = mongoose.Schema;

    module.exports.mongoose = mongoose;
    module.exports.Schema = Schema;

    // Connect to cloud database
    var username = "myusername";
    var password = "mypassword";
    var address = ' @ds045147.mongolab.com:45147/mydatabasename';
    connect();

    // Connect to mongo
    function connect() {
    var url = 'mongodb://' + username + ':' + password + address;
    mongoose.connect(url);
    }

    function disconnect() { mongoose.disconnect(); }

    // ...................................................................................

    Any suggestions on what I may be doing wrong? Thanks in advance for any help.

    MN

  2. #2
    Under Construction silver trophybronze trophy AussieJohn's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    776
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    Hi Mnaz and welcome to the forums.

    Try removing the space at the front of the address. There is a print error in the book / code typo - that space shouldn't be there.

    i.e.
    Code:
    var address = ' @ds045147.mongolab.com:45147/mydatabasename';
    ---------------^
    
    //should be
    var address = '@ds045147.mongolab.com:45147/mydatabasename';
    var details = {
    . . web: "afterlight.com.au",
    . . photos: "jvdl.id.au",
    . . psa: "usethelatestversion.com"
    }

  3. #3
    SitePoint Member
    Join Date
    Dec 2012
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, it's working.

    Try removing the space at the front of the address. There is a print error in the book / code typo - that space shouldn't be there.

    i.e.
    Code:
    var address = ' @ds045147.mongolab.com:45147/mydatabasename';
    ---------------^
    
    //should be
    var address = '@ds045147.mongolab.com:45147/mydatabasename';
    [/QUOTE]


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •