0

I am creating a backend service for a MongoDB database and I am using Mongoose to work on the db. Someone created all the fields with all lowercase letters on the database and if I don't create the schemas with the exact casing and I use camel casing on my schemas and interfaces so none of my queries work. Is there a way to ignore casing on field names or specify the collection property directly when creating the schema?

EDIT: This is something I can do with golang mongo-driver:

type Company struct {
    ID        primitive.ObjectID `bson:"_id"`
    Name      string             `bson:"name"`
    Address   string             `bson:"address"`
    TaxNumber string             `bson:"taxnumber"`
}

All the field names on the collection are all lowercase but the struct field names are all PascalCase.

Élodie Petit
  • 5,774
  • 6
  • 50
  • 88
  • you can specify collection names in two ways as described [here](https://stackoverflow.com/questions/58390480/mongodb-collection-name/58394429#58394429) – SuleymanSah Jan 09 '20 at 15:07
  • Does this answer your question? [Mongoose: ref custom field name](https://stackoverflow.com/questions/51499983/mongoose-ref-custom-field-name) – Robert Moskal Jan 09 '20 at 15:39
  • @SuleymanSah I'm not asking about specifying collection names. My problem is with the field names. – Élodie Petit Jan 10 '20 at 06:48

0 Answers0