How can I specify or in other words enforce a particular type when inserting a document? For example,
{
a: 1,
b: 2
},
{
a: 1.5,
b: 1.5
}
and I would like to define to MongoDB to threat all fields as Double in this case. This is because there's no such thing as Integer in JavaScript an all Integers are Doubles by default although the decimal point vanishes when there is no decimal point. This behavior actually causes a problem when inserting documents to MongoDB from NodeJS because it is weakly typed.
I would like to emphasize that I'm not a big fan of Mongoose and please do not suggest me to use that! I wanna know how to explicitly specify types when inserting using the original MongoDB driver.