I'm studying mongoose and am facing a problem.
When trying to use find it just returns an empty vector while it should return all of MongoDB.
Here is the code.
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
mongoose.connect('mongodb://127.0.0.1:27017/test');
var db = mongoose.connection;
db.on('error', console.error.bind(console, 'connection error:'));
db.once('open', function() {
// we're connected!
console.log("Conectado");
});
var usuarioSchema = new mongoose.Schema({
nome: String,
senha: String
});
var Usuario = mongoose.model('usuario', usuarioSchema);
var us1 = new Usuario({nome:"sheldon",senha:"21456"});
db.collection('usuario').insertOne(us1);
Usuario.find(function(err,docs){
console.dir(docs);
});