Alle has asked for the wisdom of the Perl Monks concerning the following question:

I have a question

I used perl's mongodb driver MongoDB(0.45),I insert a integer:

begin code----------------- use MongoDB; use MongoDB::OID; my $conn = MongoDB::Connection->new(); my $db = $conn->test; $db->id->insert({"id1"=>1,"id2"=>2}); end code-------------------

On the mongo shell,i found the "id1" and "id2" become:

> "id1" : NumberLong(1),"id2" : NumberLong(2)
But i want :
"id1" : 1,"id2":2
Who can help me,thks? my os is 64 bit and mongodb version is v1.8.1

Replies are listed 'Best First'.
Re: MongoDB or Perl Data type?
by Mr. Muskrat (Canon) on Aug 21, 2012 at 19:22 UTC

      thank you,but no answer.

      the driver's author Kristina reply me with:

      'This is intentional, Perl saves all numbers as 64-bit integers on 64-bit platforms, and NumberLong is how the shell displays 64-bit numbers. See http://www.mongodb.org/display/DOCS/Overview+-+The+MongoDB+Interactive+Shell#Overview-TheMongoDBInteractiveShell-Numbers.'

      insert number using mongodb shell is ok,it just a basic number,but use perl driver MongoDB,it became NumberLong(*) ,who can help me?

        thank you,but no answer. the driver's author Kristina reply me with: 'This is intentional, Perl saves all numbers as 64-bit integers on 64-bit platforms, and NumberLong is how the shell displays 64-bit numbers. See http://www.mongodb.org/display/DOCS/Overview+-+The+MongoDB+Interactive+Shell#Overview-TheMongoDBInteractiveShell-Numbers.' insert number using mongodb shell is ok,it just a basic number,but use perl driver MongoDB,it became NumberLong(*) ,who can help me?

        I think you just got your answer, there is nothing you can do about it (short of writing your own MongoDB driver)

Re: MongoDB or Perl Data type?
by Anonymous Monk on Aug 21, 2012 at 09:43 UTC

    But i want

    Why? How do you know you can control that?

      ...... How Control?

        ...... How Control?

        How do you know that you can? That its possible? Allowed? A feature? Can be done?

        Do you understand my question now? Looking how to do something, without knowing if its at all possible, seems like a large waste of time to me