Message from discussion
Insertion of integer becomes double as a result of JavaScript
Received: by 10.43.81.137 with SMTP id zy9mr1361974icb.0.1347920371660;
Mon, 17 Sep 2012 15:19:31 -0700 (PDT)
X-BeenThere: mongodb-user@googlegroups.com
Received: by 10.231.4.209 with SMTP id 17ls15674215ibs.6.gmail; Mon, 17 Sep
2012 15:19:19 -0700 (PDT)
Received: by 10.50.209.71 with SMTP id mk7mr4199531igc.4.1347920359943;
Mon, 17 Sep 2012 15:19:19 -0700 (PDT)
Received: by 10.50.209.71 with SMTP id mk7mr4199529igc.4.1347920359929;
Mon, 17 Sep 2012 15:19:19 -0700 (PDT)
Return-Path: <r...@windofkeltia.com>
Received: from mail-ob0-f181.google.com (mail-ob0-f181.google.com [209.85.214.181])
by gmr-mx.google.com with ESMTPS id xd1si2928391igb.1.2012.09.17.15.19.19
(version=TLSv1/SSLv3 cipher=OTHER);
Mon, 17 Sep 2012 15:19:19 -0700 (PDT)
Received-SPF: neutral (google.com: 209.85.214.181 is neither permitted nor denied by best guess record for domain of r...@windofkeltia.com) client-ip=209.85.214.181;
Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 209.85.214.181 is neither permitted nor denied by best guess record for domain of r...@windofkeltia.com) smtp.mail=r...@windofkeltia.com
Received: by obbwd18 with SMTP id wd18so10712344obb.12
for <mongodb-user@googlegroups.com>; Mon, 17 Sep 2012 15:19:19 -0700 (PDT)
d=google.com; s=20120113;
h=message-id:date:from:user-agent:mime-version:to:subject:references
:in-reply-to:content-type:content-transfer-encoding
:x-gm-message-state;
bh=h0Iui/HM9Y0fv3w5b21q7fn/DHZcSChCmJ5Avfl5h5A=;
b=J8az2AK5lkKD6S9ijSIHCZ33QIeetUqO11QZh68YcIUQ/JSP1W1S1AG5hbu+tVUUbZ
eCKNyp3H6jiM8OooPOQKIzxazypwXXJd7zaz951RIwYgJdzZY5g7SJbsEAOxWSydOwt8
rralh9wdH8liRUiNM972XGhuWM00fnNqnjJjNRXV/HfHd63oRygEHaI4SIXvKbLYs74Z
opCqxXH6qxxYAw/8sQ16CWTEm/deHQrNRzAxocASJTv55x3QF6Ew1EUr/JtSnwNO4LPz
tHg7ym9XaEmxU6+GOQw+5ib+AWYSIwdVXimoBO9ENB36zUXluTq6dSHDPaqM3WKCvPvq
DQMw==
Received: by 10.182.179.100 with SMTP id df4mr13512229obc.59.1347920359438;
Mon, 17 Sep 2012 15:19:19 -0700 (PDT)
Return-Path: <r...@windofkeltia.com>
Received: from [0.0.0.0] (c-98-202-115-247.hsd1.ut.comcast.net. [98.202.115.247])
by mx.google.com with ESMTPS id hz6sm12110164obb.1.2012.09.17.15.19.14
(version=SSLv3 cipher=OTHER);
Mon, 17 Sep 2012 15:19:15 -0700 (PDT)
Message-ID: <5057A20E.2010...@windofkeltia.com>
Date: Mon, 17 Sep 2012 16:19:58 -0600
From: Russell Bateman <r...@windofkeltia.com>
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20120907 Thunderbird/15.0.1
MIME-Version: 1.0
To: mongodb-user@googlegroups.com
Subject: Re: [mongodb-user] Insertion of integer becomes double as a result
of JavaScript
References: <505780C2.30...@hp.com> <505784F4.7000...@windofkeltia.com> <CALOM=qiTrDq92+Jmamhg7jyBneysmkRCNivfZdcBBkYPEUp...@mail.gmail.com>
In-Reply-To: <CALOM=qiTrDq92+Jmamhg7jyBneysmkRCNivfZdcBBkYPEUp...@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Gm-Message-State: ALoCoQl/OY+kQEGZEBu5guHqdcy1f4Ch2cgKAVSYcojp+mLZ7DnRmRY7q/dy40dTemohYtB3Z0zu
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+Interactive+Shell#Overview-TheMongoDBInteractiveShell-Numbers
>
> 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