Mongoose find() returns a property of the model


ek

I am trying to find existing users using mongoose my query is

UserAccount.find(variables, function (error, success) {
            if (error) {
                response.send({status: false});
            } else {
                console.log(success);
            }
        }); 

Returns the following array if the user exists.

[ model {
        '$__':
         InternalCache {
           strictMode: true,
           selected: [Object],
           shardval: undefined,
           saveError: undefined,
           validationError: undefined,
           adhocPaths: undefined,
           removing: undefined,
           inserting: undefined,
           saving: undefined,
           version: undefined,
           getters: {},
           _id: 5c98e64f2106e94022532c9f,
           populate: undefined,
           populated: undefined,
           wasPopulated: false,
           scope: undefined,
           activePaths: [StateMachine],
           pathsToScopes: {},
           session: null,
           ownerDocument: undefined,
           fullPath: undefined,
           emitter: [EventEmitter],
           '$options': [Object] },
        isNew: false,
        errors: undefined,
        _doc:
         { isActive: true,
           _id: 5c98e64f2106e94022532c9f,
           userName: '[email protected]',
           password:
            '$2a$05$vpowA76cB3T/4eHGbQPqd.F/iIebX7SXKPZA2k1wcmlSIDks0q852',
           userCategory: 'buyer',
           createdDate: 2019-03-20T14:31:43.250Z,
           updatedDate: 2019-03-20T14:31:43.250Z,
           __v: 0 },
        '$init': true } ]

I don't know what is causing this problem? Until yesterday, it only returned user data, but that's weird to me. how to solve this problem? Can someone help me with this problem? thanks.

Lokeshkumar S

I also faced the same problem, the probe is: if you are using the latest version of mongo and older mongoose, it can be solved by installing the newer version of mongoose and running mongoose find(), which will solve your probe problem.

Related


Model.find() returns null after Model.save() in Mongoose + Nodejs

Karpesh Priciani The save function works perfectly, but the find function below it returns null when searching for previously saved save objects. Here is the code: var mongoose = require("mongoose"); var User = mongoose.model("User"); module.exports.register

Returns variables declared in Mongoose find()

Yu Chen I'm having a lot of trouble using for loops with promises. Essentially, my workflow is: ArtistGet a set of objects in Node.js and use Mongoose to get their biography and ID. Get all artworks created by this artist using their IDs (more specifically, al

mongoose.find() returns undefined

hiro Shiro [MongoDB] I'm trying to get objects namefrom all documents in a collection . But console.log(users.name)returns undefined. Data.find({}, 'name', function (err, users) { if (err) { console.log(err); } else { console.log(users.name)

mongoose.find() returns undefined

hiro Shiro [MongoDB] I'm trying to get objects namefrom all documents in a collection . But console.log(users.name)returns undefined. Data.find({}, 'name', function (err, users) { if (err) { console.log(err); } else { console.log(users.name)

Mongoose find() returns an empty document

reason Why does this function return an empty document? There is also a function that uses find({}) without any query and it works. router.get('/mesCandidatures/:id', function(req, res, next) { Models.Candidature.find({"figurant":req.params.id}, function(e

mongoose.find() returns undefined

hiro Shiro [MongoDB] I'm trying to get objects namefrom all documents in a collection . But console.log(users.name)returns undefined. Data.find({}, 'name', function (err, users) { if (err) { console.log(err); } else { console.log(users.name)

Mongoose model.find() returns an empty collection

Muchin 777 I have this model const BlockModel = Mongoose.model('blocks', { height: Number, size: Number, time: Number }) This API call (hapi.js) server.route({ method: "GET", path: "/api/blockinfo", handler: async (request, h) => {

.find field mongoose returns nothing

Stephen I can't seem to figure out what's wrong. I'm having trouble using the Mongoose find function to return all records that match a field. Can anyone point out what I'm doing wrong? // GraphQL query { getFieldsByForm(formID:"1234"){ formID, label

Mongoose model.find(filteredQuery) returns empty array

Bart I have a Node.js backend that communicates with my MongoDB and I need to filter out some results from the database. The problem is that when I send the query I just receive an empty array in return. function setTOQuery() { let path;

Express Mongoose Model.find() returns undefined

the hole Hey, there is a problem. Try sending an Express response containing Mongo data. Here is the code in my express server var Task = require('./modules/Task'); app.get('/get-all-tasks',function(req,res){ res.setHeader('Content-Type', 'application/json

find({}) returns an empty array mongoose

Shofer This is my code in model.js file: const mongoose = require("mongoose"); const con = require("./connection"); con(); const schoolNotices = mongoose.model("schoolNotices", { title:{ type: String }, date:{ type:String }, detai

Mongoose find returns no results

George Talida I have a method called getTeamEmployees which is supposed to get the employees whose teamId is equal to the method parameter teamId. It looks like this: public getTeamEmployees(teamId: number): Promise<any> { return MDBDatabaseController.Empl

Mongoose model.find() returns an empty collection

Muchin 777 I have this model const BlockModel = Mongoose.model('blocks', { height: Number, size: Number, time: Number }) This API call (hapi.js) server.route({ method: "GET", path: "/api/blockinfo", handler: async (request, h) => {

Mongoose model.find(filteredQuery) returns empty array

Bart I have a Node.js backend that communicates with my MongoDB and I need to filter out some results from the database. The problem is that when I send the query I just receive an empty array in return. function setTOQuery() { let path;

Model.find() returns null after Model.save() in Mongoose + Nodejs

Karpesh Priciani The save function works perfectly, but the find function below it returns null when searching for previously saved save objects. Here is the code: var mongoose = require("mongoose"); var User = mongoose.model("User"); module.exports.register

Model.find() returns null after Model.save() in Mongoose + Nodejs

Karpesh Priciani The save function works perfectly, but the find function below it returns null when searching for previously saved save objects. Here is the code: var mongoose = require("mongoose"); var User = mongoose.model("User"); module.exports.register

Model.find() returns null after Model.save() in Mongoose + Nodejs

Karpesh Priciani The save function works perfectly, but the find function below it returns null when searching for previously saved save objects. Here is the code: var mongoose = require("mongoose"); var User = mongoose.model("User"); module.exports.register

mongoose.find() returns undefined

hiro Shiro [MongoDB] I'm trying to get objects namefrom all documents in a collection . But console.log(users.name)returns undefined. Data.find({}, 'name', function (err, users) { if (err) { console.log(err); } else { console.log(users.name)

find({}) returns an empty array mongoose

Shofer This is my code in model.js file: const mongoose = require("mongoose"); const con = require("./connection"); con(); const schoolNotices = mongoose.model("schoolNotices", { title:{ type: String }, date:{ type:String }, detai

Mongoose find nested model?

Michael Joseph Aubrey Here's an idea of what my mongodb document looks like (in json format of course) [ { _id: 50, team_name: 'bulls', players: [ { _id: 100, player_name: 'Jokim'

Mongoose find by reference returns nothing

Tom Soderlund Here is the data from the mongo client: > db.projects.find({ })[1]; { "name" : "App 276", "slug" : "app276", "createdByUser" : ObjectId("52f20518b66ae3622c000002"), "_id" : ObjectId("52fc91f508e3507c19000002"), "screens" : [ ]

Mongoose find() returns no results

username I have a routing setup that uses a model called Todo like this: app.get('/api/todos', function(req, res) { Todo.find({},function(err, todos) { if (err) res.send(err); console.log("number of todos " + todos.length);

Model.find() returns null after Model.save() in Mongoose + Nodejs

Karpesh Priciani The save function works perfectly, but the find function below it returns null when searching for previously saved save objects. Here is the code: var mongoose = require("mongoose"); var User = mongoose.model("User"); module.exports.register

Model.find() returns null after Model.save() in Mongoose + Nodejs

Karpesh Priciani The save function works perfectly, but the find function below it returns null when searching for previously saved save objects. Here is the code: var mongoose = require("mongoose"); var User = mongoose.model("User"); module.exports.register

Model.find() returns null after Model.save() in Mongoose + Nodejs

Karpesh Priciani The save function works perfectly, but the find function below it returns null when searching for previously saved save objects. Here is the code: var mongoose = require("mongoose"); var User = mongoose.model("User"); module.exports.register

Mongoose find() returns a property of the model

ek I am trying to find existing users using mongoose my query is UserAccount.find(variables, function (error, success) { if (error) { response.send({status: false}); } else { console.log(success);

Mongoose find() returns a property of the model

ek I am trying to find existing users using mongoose my query is UserAccount.find(variables, function (error, success) { if (error) { response.send({status: false}); } else { console.log(success);

Model.find() returns null after Model.save() in Mongoose + Nodejs

Karpesh Priciani The save function works perfectly, but the find function below it returns null when searching for previously saved save objects. Here is the code: var mongoose = require("mongoose"); var User = mongoose.model("User"); module.exports.register

Mongoose find() returns no results

username I have a routing setup that uses a model called Todo like this: app.get('/api/todos', function(req, res) { Todo.find({},function(err, todos) { if (err) res.send(err); console.log("number of todos " + todos.length);