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

135
Views
TypeError: Cannot read properties of undefined (reading 'push') when trying to push to a mongoDB

This is what the code looks like:

import { MongoClient } from 'mongodb';
import { config } from 'dotenv';
config();

export async function connectToCluster() {
    let mongoClient;
    const dbOptions; //Assume that this exists.
    mongoClient = new MongoClient(process.env.MONGO_URI, dbOptions);
    await mongoClient.connect();
    return mongoClient;
}

db = await connectToCluster();
temp = db.db('Database').collection('data').find({}).limit(1).database.push(JSON.parse(data));

This gives the aforementioned error even though "database" is a field in the collection "data" in the db "Database". Console-logging the entire thing up to .database gives undefined.

about 4 years ago · Juan Pablo Isaza
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!