Select field and multi select and gender and birthday datatypes in mongodb

 Nom:{type:String, required :true},
    Prenom:{type:String, required :true},
    Birthday: Date,
    Email: {type:String, required :true},
  /* enum:"ariana","beja" "benarous","bizerte","gabes","gafsa","jendouba","kairouan","kasserine","kebili","kef","mahdia","manouba","mednine","monastir","nabeul","sfax","sidi bouzid","silliana","sousse","tataouine","tozeur","tataouine""zaghouan"*/
    Hobbies:{type:String}, this is the multiple select


export default  mongoose.model('User',userSchema)

in fact it cause a lot of problems i m building an authentification app and when i submit this message from the server shows up

Hello @Nour_ha, welcome to the MongoDB Community forum!


Gender: { type: String,
          enum: "homme"||"Femme" 

you can only assign a string value to the Gender, and this value can be one of “homme” or “Femme”. For example,

Gender: "homme"

From the documentation (Mongoose - Built-in Validators) it shows that the Gender can be defined as:

Gender: { type: String,
          enum: [ "Homme", "Femme" ]
1 Like

i tried at first but when i try to submit the form it shows me "error :User failed :Fender:`` is not a valid enum value for path Gender also i have to other select menus where when i send data they don t arrive to server when i leave it just a string the error diseppear but no data sent to server same as the other select menu gouvernorat (which means states the user choose 1from 24 options) and the multiple select Cinteret or hobbies where the user can select many options

Hello @Nour_ha, Generally the data from the form is received as strings and these are mapped to the data in the database thru the application. As you know, the application connects to the database via a driver (possibly with mapping using an ODM).