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

307
Views
Cannot connect loopback model to mongo db collection

I have a mongo db collection named like "name.types". When I am creating model for the collection in loopback, I cannot enter the model name with the "." as it says special characters not allowed. So I created the model as "name_types". Now how can I connect this model to the collection "name.types"? Any help would be appreciated. Thanks!

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

You can set collection name in model.json file :

//model.json

...
"options": {
    "validateUpsert": true,    
    "mongodb": {
      "collection": "name_types"
    }
  },
....
over 4 years ago · Santiago Trujillo Report

0

You can define a different collection name for your existing model by passing an option in model definition, something like this

    Post = db.define('Post', {
      title: { type: String },
      content: { type: String }
    }, 
    {
      mongodb: {
        collection: 'PostCollection', // Custom the collection name
       }
   });

You can do it from the model.json file or from a boot script. Good Luck.. :)

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!