Hello, How can we make sure a filed has specific type when we inserting? For example, when we insert document in compass we can specify int32 for year filed but how do we do it in mongo shell?
Mongo Shell automatically inferred the data type of the value. But you can still use built-in helper methods like NumberLong, NumberInt, NumberDecimal for some specific type. I hope the answer helps
According to mongodb online manual Data Types in mongo shell
Thank you Sidoine_Komi., yes it helped. mongo shell automatically inferred as data type of double for year.
using following we can make sure data type of int32 for year.
Great… Happy learning dear