I must be doing something wrong in my JavaScript. I insert the
construct (document) below and the "addresstype" comes back, as seen
from the Java driver, as 1.0 or 2.0 instead of as an integer. I'm
sure it's the fault of the JavaScript file I'm populating test data
with since if I add an address through my application, this doesn't
happen. When I do
this.addresstype = ( Integer ) bson.get( "addresstype" );
In the debugger, I see
... "addresstype": 1.0
etc. Obviously, I crash with:
java.lang.Double cannot be case to java.lang.Integer
How should I write this field in my JS script?
Thanks in advance.
db.accounts.insert(
{
"password":password_test123,
"email": "ven...@fun.com",
"partneroid":partnerx_partneroid,
"created":created,
"language":"en",
"forgotten":false,
"username":venkatname1,
"firstname":"Venkat",
"lastname":"Mynampati",
"fullname":"Venkat Mynampati",
"birthdate":ISODate( '1973-01-01 12:12:12' ),
"phone":"510-987-9874",
"mobile":"510-987-9874",
"fax":"510-987-9874",
"avatar":null,
"accountdata" :
{
"favoritefriend":"Levi Miller",
"favoritecolor":"white",
"bestchoice":"selection7",
"nationalanthem":"String of Pearls",
"bestbeach":"sandy",
"menuscheme":"tandy"
},
"addresses" :
[
{
"oid":new ObjectId().toString(),
"addresstype":1,
"fullname":"Venkat
Mynampati",
"street1":"1234 Mariposa Drive",
"street2":null,
"street3":null,
"city":"Fremont",
"state":"ca",
"country":"us",
"postalcode":"94536",
"language":"en",
"lastupdate":created,
"created":created
},
{
"oid":new ObjectId().toString(),
"addresstype":2,
"fullname":"Venkat
Mynampati",
"street1":"P. O. Box 356",
"street2":null,
...