Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

72
Views
Mongoose how to get a object length?

I wanto to get a length of an object using the mongoose lib

here is my code

const mongo = require("../../server") // model call
    
     {...}
    
    var query = 'email@email.com'; //get an email
        var db = mongo.connection;
        
        db.db.collection("user").findOne({email:query}, function(err, result) {
    
          if (err) throw err; 
          if ( result.length > 0) {...} // here I want to get my object length

In result.length Im getting an error because there's no length in my object , so someone know's how can I get it ?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can use Object.keys(result).length to get the length of entries

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!