从文档中获取信息

Get information from a document

我想知道如何检索文档中的所有信息并将其用于 discord.js 嵌入。

我当前的文档:

我当前的代码:

mongoose.connect('mongodb://¤¤¤¤¤¤¤¤¤¤¤/practice', function(err, db) {
  if (err) {
    throw err;
  }
  db.collection("profiles").find({
    uuid: `${uuid}`
  }, {
    kitStatistics: 1
  }).toArray(function(err, result) {
    if (err) {
      throw err;
    }
    console.log(result);
  });
});

message.delete();
let embed = new Discord.RichEmbed()
  .setAuthor(`Elorion.net`, `https://image.noelshack.com/fichiers/2019/06/7/1549795460-logo-elorionnetwork.png`)
  .setColor(color.elorion)
  .addField("Username", username)
  .addField("UUID", uuid)
  .addField("BuildUHC Elo", result)
  .addField("NoDebuff Elo", result)
  .addField("Debuff Elo", result)
  .addField("AxePvP Elo", result)
  .addField("Combo Elo", result)
  .addField("Archer Elo", result)
  .addField("Skin", `[Download](https://crafatar.com/skins/${uuid}.png)`)
  .setThumbnail(`https://crafatar.com/avatars/${uuid}.png?size=400&overlay=true`)
  .setFooter(`Ⓒ Elorion.net 2019. All rights reserved`);
message.channel.send(embed)

当我看你的数据结构时,你真的需要记住什么是对象,什么是数组。

在您的示例 BuildUHC 中,要获得 elo 属性,您需要 result[0].kitStatistics.BuildUHC.elo

我将Arrays and Objects的MDN文章留在这里。