Re: [nodejs] Error: database names cannot contain the character '.'

1,765 views
Skip to first unread message

Daniel Rinehart

unread,
Dec 7, 2012, 5:35:34 PM12/7/12
to nodejs
Remove the space before the @ sign in your address variable.

-- Daniel R. <dan...@neophi.com> [http://danielr.neophi.com/]


On Fri, Dec 7, 2012 at 2:40 PM, man12 <mnaz...@gmail.com> wrote:
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";
connect();

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

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

man12

unread,
Dec 7, 2012, 7:42:52 PM12/7/12
to nod...@googlegroups.com
Space is not there.  That's just a typo on my part. 

Ryan Schmidt

unread,
Dec 7, 2012, 9:09:08 PM12/7/12
to nod...@googlegroups.com
Do the variables username or password contain spaces, colons, slashes or other special characters? If so they need to be percent-encoded for use in a URL.

Joe

unread,
Dec 23, 2012, 8:15:38 AM12/23/12
to nod...@googlegroups.com
you need change ' to " in address definition.
the correct one should be

it fixes your problem. Happy Hollidays!


On Friday, December 7, 2012 2:40:00 PM UTC-5, man12 wrote:
I am in the process of learning node.js and using mongoose for Mongodb.  I am following an example from a tutorial to connect to hosted mongodb.  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";
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

Ryan Schmidt

unread,
Dec 23, 2012, 5:40:48 PM12/23/12
to nod...@googlegroups.com
Why in the world would that make any difference? A string is a string, regardless whether you use single or double quotes.
Reply all
Reply to author
Forward
0 new messages