I have a user collection which has 1000 documents,when i call find()
function using mongoose
in node.js
,it does not return any result or throw any error. But when i query through mongo shell it returns all results.
Neither the docs nor the err is getting consoled,it just hangs.The same query is working when queried for less no. of documents.
var userschema = require('./models/profile.js');
userschema.find({ 'dept_id': data }, function(err, docs) {
if (err)
console.log(err);
console.log(docs);
});
profile.js
var mongoose = require('mongoose');
var profileSchema = new mongoose.Schema({
dept_id:{
type:String,
default:''
},
email:{
type:String,
default:''
},
loggedin_time:{
type:Number,
default:0
},
phone_number:{
type:String,
default:''
},
password:{
type:String,
default:''
},
gender:{
type:String,
default:''
},
dob:{
type:String,
default:''
},
profile_pic:{
type:String,
default:''
},
city:{
type:String,
default:''
},
state:{
type:String,
default:''
},
country:{
type:String,
default:''
},
last_seen:{
type:String,
default:''
}
});
module.exports = mongoose.model('profiles',profileSchema);
Thank you.