F
F
freestm2017-09-06 21:44:16
JavaScript
freestm, 2017-09-06 21:44:16

How to get value in mongodb?

There is the following example in the off.doc:

MongoClient.connect(uri, function (err, db) {
  db.collection('inventory').insertMany([
    {
      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"]
    }
  ])
    .then(function (result) {
      // process result
    })
    var cursor = db.collection('inventory').find({ status: "D" });
  db.close();
});

How to work with "cursor" further? how to get for example the value of the "item" key?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Philipp, 2017-09-06
@freestm

https://youtu.be/Do_Hsb_Hs3c?t=689

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question