I have opened a connection to my remote mongodb ec2 instance but now am trying to retrieve data that is nested within a collection. The database has multiple collections (ie visitor, campaign, form, etc...) and has data already in it from another source. I am using node + express for the application.
1) Do I have to define a schema in my app to match the remote database or can I just query for the data and store it in an object? mongoose schema creation
2) Actually retrieving the values within the visitor collection, can I just use dot notation to query within the visitor
collection for visitor_id
using:
db.find(visitor.visitor_id)
Here is the database connection code I am using if that helps
var uri = 'mongodb://xx.xxx.xx.x'
var mongoOptions = { db: { safe: true } };
db = mongoose.createConnection(uri, mongoOptions, function (err, res) {
if (err) {
console.log('ERROR connecting to: remote' + uri + '. ' + err);
} else {
console.log('Successfully connected to: remote' + uri);
}
});