Hello All,
I am fooling with MongoDB and Perl and have a simple question - how do I maintain the order of data fields upon an insert? My code is the following:
############################################
#!usr/bin/perl
use MongoDB;
use MongoDB::Database;
use MongoDB::OID;
my $conn = MongoDB::Connection->new;
my $db = $conn->test;
my $users = $db->testlogwiki;
$users->insert
(
{
"product" => "WooHoo",
"errcode" => "WM2001_89873",
"solution1" => "Hit the computer.",
"line_text" => "Inserted in Perl too"
}
);
#####################################
But when I lookup the record in mongoDB via the mongo query shell:
"_id" : ObjectId("4fc62c2900ece6040c000000"),
"solution1" : "Hit the computer.",
"product" : "WooHoo",
"errcode" : "WM2001_89873",
"line_text" : "Inserted in Perl too"
That's not the order I inserted! How do I fix this?
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.