如何使用快速数据库列出存储的数据?

How to list stored data using quick db?

我尝试使用 list 命令来列出此代码的存储数据,我尝试了很多但它对我不起作用,

client.on("message", message=>{
    if(!message.guild)return;
    if(message.content.startsWith(prefix + "add")){
    let user = message.mentions.users.first()
        
        if(!user) return message.channel.send('**:x: You have to mention someone first.**')
            if(db.fetch(`owner_${user.id}`)) return message.channel.send("**This user is already exists**")
        
        db.set(`owner_${user.id}`, true)
        message.channel.send(new Discord.MessageEmbed().setColor('#4C6E70').setDescription(`**${user} Done.**`)).then(async msg => {
            msg.react("✅")
        })
    }
 }
    });

您现在显示的命令是将所有者添加到您的机器人的命令,与列出它们无关,如果您想显示 quick.db 数据库中关于您的所有数据,只需使用 db.all()

Altought 如果你想要更高效的东西,我建议你开始使用数组来存储你的机器人的所有者 db.push() 它看起来像这样:

client.on("message", message=>{
    if(!message.guild)return;
    if(message.content.startsWith(prefix + "add")){
    let user = message.mentions.users.first()
        
        if(!user) return message.channel.send('**:x: You have to mention someone first.**')
            let owners = db.get('owners') || [] // If there's no owners it will always return an empty array
            if(owners.includes(user.id)) return message.channel.send("**This user is already exists**")
        
        db.push(`owners`,user.id)
        message.channel.send(new Discord.MessageEmbed().setColor('#4C6E70').setDescription(`**${user} Done.**`)).then(async msg => {
            msg.react("✅")
        })
    }
 }
    });

设置数组后,要列出所有者,您可以使用 db.get() !

    // ...
    if(message.content.startsWith(prefix + "owners")){
      let owners = db.get('owners')
      if(!owners) return message.channel.send('There are no owners!')
      else  message.channel.send('The owners are ' + owners.join(' and '))
    }