简体   繁体   English

如何删除 mongoDB discord.js v13 中的字段

[英]How to delete a field in mongoDB discord.js v13

I have 5 fields in my document.我的文档中有 5 个字段。 I want to turn this,我想转这个

  autoRole1: {
    type: String
  },
  autoRole2: {
    type: String
  },
  autoRole3: {
    type: String
  },
  autoRole4: {
    type: String
  },
  autoRole5: {
    type: String
  }

To this(for example):对此(例如):

  autoRole1: {
    type: String
  },
  autoRole3: {
    type: String
  },
  autoRole4: {
    type: String
  },
  autoRole5: {
    type: String
  }

How can I do it?我该怎么做? This is the code I've tried:这是我尝试过的代码:

const Welcome = require('../../models/Guild');
Welcome.update({guildId: message.guild.id}, { $unset: { "autoRole1": 1 } }, { multi: false });

did you try it like below?你试过像下面这样吗? source 资源

Welcome.update({guildId: message.guild.id}, { $unset: { "autoRole1": "" } }, { multi: false });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM