fix: superfluous fields after converting guild to client representation
This commit is contained in:
parent
c5666dc387
commit
e066f0f23f
@ -2,14 +2,18 @@ import { IGuild } from "@/src/types/guildTypes";
|
|||||||
import { model, Schema } from "mongoose";
|
import { model, Schema } from "mongoose";
|
||||||
import { toOid } from "@/src/helpers/inventoryHelpers";
|
import { toOid } from "@/src/helpers/inventoryHelpers";
|
||||||
|
|
||||||
const guildSchema = new Schema<IGuild>({
|
const guildSchema = new Schema<IGuild>(
|
||||||
|
{
|
||||||
Name: { type: String, required: true }
|
Name: { type: String, required: true }
|
||||||
});
|
},
|
||||||
|
{ id: false }
|
||||||
|
);
|
||||||
|
|
||||||
guildSchema.set("toJSON", {
|
guildSchema.set("toJSON", {
|
||||||
virtuals: true,
|
virtuals: true,
|
||||||
transform(_document, guild) {
|
transform(_document, guild) {
|
||||||
guild._id = toOid(guild._id);
|
guild._id = toOid(guild._id);
|
||||||
|
delete guild.__v;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user