我一直在玩 Perl MongoDB 库,并且很难弄清楚如何做一些非常简单的事情。
如何在插入时维护数据字段的顺序?我的代码如下:
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"
}
);
当我返回并在我的 MongoDB 中查找记录的插入方式时,它看起来像这样:
db.testlogwiki.find([找到它的标准]).pretty();
"_id" : ObjectId("4fc62c2900ece6040c000000"),
"solution1" : "Hit the computer.",
"product" : "WooHoo",
"errcode" : "WM2001_89873",
"line_text" : "Inserted in Perl too"
这不是我想要的顺序......我如何使它成为我想要的顺序?