MongoDB如何有效地存储数据?

问题描述 投票:0回答:1

有人可以帮我理解mongoDB如何有效地存储和检索数据。

在文档中,它显示了以下示例。要插入:

db.inventory.insertMany([
   // MongoDB adds the _id field with an ObjectId if _id is not present
  { item: "journal", qty: 25, status: "A",
   size: { h: 14, w: 21, uom: "cm" }, tags: [ "blank", "red" ] },
  { item: "notebook", qty: 50, status: "A",
   size: { h: 8.5, w: 11, uom: "in" }, tags: [ "red", "blank" ] },
  { item: "paper", qty: 100, status: "D",
   size: { h: 8.5, w: 11, uom: "in" }, tags: [ "red", "blank", "plain" ] },
  { item: "planner", qty: 75, status: "D",
   size: { h: 22.85, w: 30, uom: "cm" }, tags: [ "blank", "red" ] },
  { item: "postcard", qty: 45, status: "A",
   size: { h: 10, w: 15.25, uom: "cm" }, tags: [ "blue" ] }
 ])

并检索:

  db.inventory.find( { status: "D" } )

我知道它在内部使用BSON。但有人可以让我知道它是如何工作的(可能是上面的例子)以及如何有效地存储和检索键值对。

谢谢。

json mongodb nosql bson
1个回答
0
投票
© www.soinside.com 2019 - 2024. All rights reserved.