You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello. I'm new to Nodejs and found this briliant repo to work with. It helps me to understand how nodejs works, what expressjs is and so on. This is not a bug report, but a question related with nodejs, mongoDB and this boilerplate implementation.
I came to NodeJS from PHP and relational DBs stack and I got confused: don't you use enums in backend and integers in mongo?
Let's say we have here column which can be enumed and replaced with numeric column type to make DB faster: user.role.
As much as I read I see nobody uses integers and such type of columns, but strings: status, role and so on.
In PHP and relational DB stack we had enums and numeric values and in DB we stored the value of that enum so DB could query with that columns faster. Does not it work here?
The text was updated successfully, but these errors were encountered:
Mongoose String and Number types have an enum validator. The enum validator is an array that will check if the value given is an item in the array. If the value is not in the array, Mongoose will throw a ValidationError when you try to save().
consttestSchema=newmongoose.Schema({status: {type: String,enum: ['valid','invalid']}})constTest=mongoose.model('Test',testSchema);awaitTest.create({name: 'not a status'});// throws validation errorawaitTest.create({name: 'valid'});// works
Hello. I'm new to Nodejs and found this briliant repo to work with. It helps me to understand how nodejs works, what expressjs is and so on. This is not a bug report, but a question related with nodejs, mongoDB and this boilerplate implementation.
I came to NodeJS from PHP and relational DBs stack and I got confused: don't you use enums in backend and integers in mongo?
Let's say we have here column which can be enumed and replaced with numeric column type to make DB faster: user.role.
As much as I read I see nobody uses integers and such type of columns, but strings: status, role and so on.
In PHP and relational DB stack we had enums and numeric values and in DB we stored the value of that enum so DB could query with that columns faster. Does not it work here?
The text was updated successfully, but these errors were encountered: