Mongoose isn't showing mongodb collection document for some collections

Viewed 68

I'm new to Node.js, Express, Mongoose and MongoDB so expecting details response please.

For our project we've created few collections in MongoDB. We're reading the collections in Node.js based server using Express & Mongoose.

There are 4 collections, each of which has at least 1 document. I'm reading 4 collections in the same way as follows:

var SnTypes = require('../models/sn_types');
var Ms = require('../models/ms');
var Users = require('../models/us');
var Rd = require('../models/rd');

Users.find({}, function (err, users) {
    if (err) return handleError(err);

    console.log('users');
    console.log(users); // <<-- this shows all users in db
});

Ms.find({}, function (err, ms) {
    if (err) return handleError(err);

    console.log('ms');
    console.log(ms);  // <<-- this shows all ms in db
});

SnTypes.find({}, '', function (err, sn) {
    if (err) return handleError(err);

    console.log('sn');
    console.log(sn); // <<-- this shows empty array []
});

Rd.find({}, '', function (err, rd) {
    if (err) return handleError(err);

    console.log('rd');
    console.log(rd); // <<-- this shows empty array []
});

Why some collection data are retrieved while for some no data are retrieved? What's the binding mechanism between node.js model to MongoDB collection?

UPDATE

I've got the answer: https://stackoverflow.com/a/53923733/68304

0 Answers
Related