[英]Remove Quotation Marks From MongoDB String
我想在 mongodb 中存储一个值,例如member.guild.name
或${member.guild.name}
但引号将其转换为字符串,因此当我输出它时,它返回为 member.guild.name 或 ${member .guild.name} 而不是公会名称,我将如何解决这个问题?
I think you're trying to make a welcome message in mongodb?我认为您正在尝试在 mongodb 中发送欢迎信息? and i've look at your code and you're calling things wrong, this will most likely fix your problem:
我查看了您的代码,但您说错了,这很可能会解决您的问题:
Your Schema:您的架构:
const guildSchema = new mongoose.Schema({
welcome: {
message: {
type: String,
required: false,
allowNull: true,
default: `Hey ${member.user.name}, welcome to **${member.guild.tag}**!`,
},
}
})
module.exports = mongoose.model(`guild`, guildSchema);
To:至:
Changed Schema:更改架构:
const guildSchema = new mongoose.Schema({
welcome: {
message: {
type: String,
required: false,
allowNull: true,
default: `Hey ${member.username}, welcome to **${message.guild.name}**!`,
},
}
})
module.exports = mongoose.model('guild', guildSchema);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.