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

395
Views
Mongoose, getting TypeError: Cannot read properties of undefined (reading 'find')

I'm getting the error, TypeError: Cannot read properties of undefined (reading 'find') which points to the block of code:

app.get('/Organizations', (req,res) => {
Organizations.find({}).then((organization) => {
    res.send(organization);
}); })

app.js, importing mongoose schema:

const {Organizations} = require('./db/models');

Organization.model.js:

const mongoose = require('mongoose');

const OrganizationsSchema = new mongoose.Schema({
    organizationName:{
        type: String,
        required: true,
        minlength:1,
        trim: true
    }
})

    
const Organizations = mongoose.model( 'Organizations', OrganizationsSchema);

module.exports =  (Organizations)

index.js:

const { Organizations } = require('./Organizations.model');
module.exports = {
    Organizations
}
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

It's an import/export problem. You added parentheses instead of brackets when exporting Organisations. Export it like so:

const mongoose = require('mongoose');

const OrganizationsSchema = new mongoose.Schema({
    organizationName:{
        type: String,
        required: true,
        minlength:1,
        trim: true
    }
})

   
const Organizations = mongoose.model( 'Organizations', OrganizationsSchema);

module.exports =  {Organizations}

And import it this way:

const { Organizations } = require('./Organizations.model');
over 4 years ago · Santiago Trujillo 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!