-1

I'm using MongoDB with mongoose and NodeJS. I have a model name where I want to include the ° symbol.

However, when I attempt to use it, I get an error in the terminal:

export default m°celsius;


SyntaxError: Invalid or unexpected token
at ESMLoader.moduleStrategy (node:internal/modules/esm/translators:115:18)
at ESMLoader.moduleProvider (node:internal/modules/esm/loader:289:14)

But without this ° symbol in the name, there is no issue.

I was reading through the limitations and naming restrictions of MongoDB here: https://www.mongodb.com/docs/manual/reference/limits/ - but I see no mention about restriction on this symbol.

Also reading through the mongoose docs about Model here: https://mongoosejs.com/docs/api/model.html - but also see no mention of this.

I recently update my NodeJS, MongoDB and Mongoose. I did not have this issue before.

Jellohouse
  • 165
  • 3
  • 12
  • Nothing to do with Mongo and everything to do with valid JavaScript symbol characters. – Phil Sep 01 '22 at 23:04

1 Answers1

1

Plainly put, the degree symbol (°) is not valid in a variable name. Instead, consider naming your model mDegCelsius or something similar, which still portrays the same information in a reasonable (and valid) format.

Delta
  • 444
  • 1
  • 4
  • 14