Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Insertion of integer becomes double as a result of JavaScript
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Russell Bateman  
View profile  
 More options Sep 17 2012, 6:19 pm
From: Russell Bateman <r...@windofkeltia.com>
Date: Mon, 17 Sep 2012 16:19:58 -0600
Local: Mon, Sep 17 2012 6:19 pm
Subject: Re: [mongodb-user] Insertion of integer becomes double as a result of JavaScript
Yes, that's it. Thanks, Scott.

On 9/17/2012 3:41 PM, Scott Hernandez wrote:

> You want to use NumberInt in javascript, much like NumberLong (for java Long)

> http://www.mongodb.org/display/DOCS/Overview+-+The+MongoDB+Interactiv...

> On Mon, Sep 17, 2012 at 4:15 PM, Russell Bateman <r...@windofkeltia.com> wrote:
>> 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,
>>                ...

>> --
>> You received this message because you are subscribed to the Google
>> Groups "mongodb-user" group.
>> To post to this group, send email to mongodb-user@googlegroups.com
>> To unsubscribe from this group, send email to
>> mongodb-user+unsubscribe@googlegroups.com
>> See also the IRC channel -- freenode.net#mongodb


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.