4 ms·
Guess what happens if you have a MongoDB ObjectId (as string) But that's a matter of semantics, not static typing. You're going to have to do type conversion o
by pdonis 13y ago
Guess what happens if you have a MongoDB ObjectId (as string)
But that's a matter of semantics, not static typing. You're going to have to do type conversion on the string regardless, because "MongoDB Objectid" isn't a native type for the compiler. But with static typing, you need to tell the compiler the type of the variable in addition to telling it how to do the type conversion: for example, in C++, you might have to say...
var MongoObjectid id = new MongoObjectid("somestring");
..whereas in Python, for example, you could just say...
id = MongoObjectid("somestring")
- mathias_10gen 13y agoActually in C++11 you can just say: auto id = mongo::OID("1234..."); This gives you much (not all) of the brevity and flexibility of dynamic typing, while maintaining the power and safety of static typing.
- annnnd 13y ago> You're going to have to do type conversion on the string regardless, because "MongoDB Objectid" isn't a native type for the compiler My point was that jQuery .data() tries to guess how to handle strings and misses in some cases, because the strings are too similar to numbers. The fact that this particular string was a MongoID is actually not relevant to the problem, it just illustrates that this is a real-world problem.