remove specific db entry
Archiviert 2 years ago
I
ItIzYe
Spielt Custom Status
Verified
so my question has part to do with discord.js. I have a command that should save a users name and a few roles. So there's the possibility for different users to have the same roles stored. i save all names and role ids in arrays because later on i will make a sorted "leaderboard" which users have which roles but i have a problem that I also made a command to delete a user and his entries from the db and when i call the command the roles of the user are getting deleted in every entry.
DB Model:
```js
const guildConfigurationSchema = new Schema({
guildId: {
type: String,
required: true,
},
userId: {
type: [String],
default: []
},
workId: {
type: [String],
default: []
},
rankId: {
type: [String],
default: []
},
teamId: {
type: [String],
default: []
}
});
```
deletion of entries:
```js
guildConfiguration.userId = guildConfiguration.userId.filter((id) => id !== workNameBack)
guildConfiguration.workId = guildConfiguration.workId.filter((id) => id !== userWorkName)
guildConfiguration.rankId = guildConfiguration.rankId.filter((id) => id !== rank)
guildConfiguration.teamId = guildConfiguration.teamId.filter((id) => id !== team)
await guildConfiguration.save();
```
that's what i came up to delete the entries but i can't figure out how to delete specific entries
