These are chat archives for Automattic/mongoose

Feb 2017
Michael Leanos
Feb 12 2017 05:04
@relentless-coder I would always capitalize the Model reference. I can't think of any case where the lowercase name would be useful. Furthermore, when you're referencing an instance of that model, the lowercase variable naming convention should be used. Using your "Kitten" model as an example..
var Kitten = mongoose.model('Kitten'); // model reference
var kitten = new Kitten({ name:  'kitty cat' }); // instance of Kitten
@relentless-coder To answer your first question, no. The var name & name of your model don't have to be the same. Your example would work, but would most likely cause confusion to anyone else looking at your code in the future. Thus, it wouldn't be best practice.
Tobias Lundgren
Feb 12 2017 11:05
Hi! I tries to deploy my app to an Ubuntu server and the Node application works fine but I cant connect to the mongodb database that are running on the same server… does anyone know what’s wrong here? I have never “deployed” an app before. I have setup auth = true in /etc/mongodb.conf and MONGODB_URI=mongodb://name:pass@ in my app’s .env file. The collections and everything exists on the server but I cannot connect to it. Good to know: Everything works fine if I use an other remote mongodb database on Heroku instead of the one on the server... Please help :)
Do I need to do anything to access the port 27017 "locally" on the remote server? It’s fine if only the local server can access the db.
Tobias Lundgren
Feb 12 2017 16:08
Problem solved! The problem was that the password contained strange symbols