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

200
Views
MongoDB Drivers - Wrap the mongodb nodejs drivers to add extra functionality

As the title says, I want to add extra methods to the mongodb drivers. Currently i'm using a collection instance to to insert, delete documents in my database like this:

// dbConn.js
const client = new MongoClient(uri);
export default const db = client.db("dbName");
//colName.js
import db form "dbConn.js"

const collection = db.collection("colName")

const data = [ ]
collection.insertMany(data)

But I would like to add some methods to the collection instance, to do something like this:

collection.modifiedInsertMany(data)

I guess, I could create my own class:

class myCollection {
  col = db.collection("collName");
  
  function modifiedInsertMany(data) {
    // do stuff with data
    return col.insertMany(data);
  }
}

But if i did that I would have to rewrite every single method of the original mongodb.Collection, isn't that correct? If possible, I want to keep all the methods of the mongodb.Collection and just add a couple of my methods.

Is it possible to do that?

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!