Javascript MongoDb更新状态
我目前正在尝试更新mongoDb中的一个文档。我是mongo的新手,阅读文档对我没有任何帮助+我没有收到任何错误 我的代码Javascript MongoDb更新状态,javascript,mongodb,Javascript,Mongodb,我目前正在尝试更新mongoDb中的一个文档。我是mongo的新手,阅读文档对我没有任何帮助+我没有收到任何错误 我的代码 const Guild = require('../schemas/GuildSchema') module.exports = { name: 'whitelist', description: "whitelist", async execute(bot, message, args, PREFIX, Discord, se
const Guild = require('../schemas/GuildSchema')
module.exports = {
name: 'whitelist',
description: "whitelist",
async execute(bot, message, args, PREFIX, Discord, settings, fs) {
if (message.author.id != "173347297181040640") {
return message.channel.send("Sorry only Bacio001 can whitelist!")
}
if (!args[1]) {
return message.channel.send("No guild id given!")
}
try {
Guild.findOneAndUpdate(
{ guildid: args[1]},
{ $set: { whitelisted : true } }
)
} catch (e) {
console.log(e);
}
let guild = bot.guilds.cache.get(args[1]);
message.channel.send(`Whitelisted ${guild.id} with the name ${guild.name} !`)
}
}
所以我最终找到了我不得不等待公会的问题。findOneAndUpdate
const Guild = require('../schemas/GuildSchema')
module.exports = {
name: 'whitelist',
description: "whitelist",
async execute(bot, message, args, PREFIX, Discord, settings, fs) {
if (message.author.id != "173347297181040640") {
return message.channel.send("Sorry only Bacio001 can whitelist!")
}
if (!args[1]) {
return message.channel.send("No guild id given!")
}
try {
await Guild.findOneAndUpdate(
{ guildid: args[1]},
{ whitelisted : true }
)
} catch (e) {
console.log(e);
}
let guild = bot.guilds.cache.get(args[1]);
message.channel.send(`Whitelisted ${guild.id} with the name ${guild.name} !`)
}
}