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

400
Views
mongoose doesn't allow me to use camelCase collection name

Here is my code:

const mongoose = require("mongoose");

mongoose.connect("mongodb://localhost:27017/miniRDS",{
        useNewUrlParser:true,
       useCreateIndex:true,
       useUnifiedTopology: true
},(err)=>{
if(!err){
    console.log("Connected")
}else{
    console.log("Couldn't connect!");
     }
});



const tests = new mongoose.Schema({
    subject:{
      type:String,
      required:true,
      default:"ict"
   },
   date:{   
      type:String,
      required:true,
     default:"01-01-2021"
    }
 });
 const testsModel = mongoose.model("classTests",tests);

const s =  new testsModel({
   subject:"english",
   date:"12-01-2021"
});
s.save();

I am using mongoose version 5.11.11. And I am facing difficulty when I try to create a collection with camelCase name using mongoose model.

In the above codes, It should create a collection name "classTests", instead it creates "classtests". how can I achieve "classTests"? Thanks

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

you can use it as:

module.exports = mongoose.model("user_notification_preference", NotificationPreference, "userNotificationPreferences");

three parameters:(the name you want to use as camel, schema, the actual name)

over 4 years ago · Santiago Trujillo Report

0

Mongoose automatically looks for the plural, lowercased version of your model name, please check this documentation, so you can't create a collection with camelCase in mongoose

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!