im attempting a "simple" connection to mongodb via an express app, the code follows:
var express = require("express");
var http = require("http");
var mongoose = require("mongoose");
//database connections
var mongoose = require("mongoose");
mongoose.connect('mongodb://localhost:27017/contactlist');
var contactSchema = new mongoose.Schema({
name: String,
email: String,
number: String
});
var Contact = mongoose.model("Contact", contactSchema);
exports.getcontactlist = function (request, response) {
console.log("connecting to mongo again...");
Contact.find({ }, function (err, docs) {
console.log(docs);
response.send(docs);
});
};
The result that is returned is always "[ ]".
Please can someone point me in the right direction?
EDIT::
Yes the database is populated