mirror of
https://github.com/spacebarchat/server.git
synced 2026-06-06 19:51:44 +00:00
🎨 remove _id and __v from response
This commit is contained in:
+41
-30
@@ -190,39 +190,50 @@ export const Embed = {
|
||||
],
|
||||
};
|
||||
|
||||
export const MessageSchema = new Schema({
|
||||
id: String,
|
||||
channel_id: String,
|
||||
author_id: String,
|
||||
webhook_id: String,
|
||||
guild_id: String,
|
||||
application_id: String,
|
||||
content: String,
|
||||
timestamp: Date,
|
||||
edited_timestamp: Date,
|
||||
tts: Boolean,
|
||||
mention_everyone: Boolean,
|
||||
mention_user_ids: [String],
|
||||
mention_role_ids: [String],
|
||||
mention_channel_ids: [String],
|
||||
attachments: [Attachment],
|
||||
embeds: [Embed],
|
||||
reactions: [Reaction],
|
||||
nonce: Schema.Types.Mixed, // can be a long or a string
|
||||
pinned: Boolean,
|
||||
type: { type: Number },
|
||||
activity: {
|
||||
type: Number,
|
||||
party_id: String,
|
||||
},
|
||||
flags: Types.Long,
|
||||
stickers: [],
|
||||
message_reference: {
|
||||
message_id: String,
|
||||
export const MessageSchema = new Schema(
|
||||
{
|
||||
id: String,
|
||||
channel_id: String,
|
||||
author_id: String,
|
||||
webhook_id: String,
|
||||
guild_id: String,
|
||||
application_id: String,
|
||||
content: String,
|
||||
timestamp: Date,
|
||||
edited_timestamp: Date,
|
||||
tts: Boolean,
|
||||
mention_everyone: Boolean,
|
||||
mention_user_ids: [String],
|
||||
mention_role_ids: [String],
|
||||
mention_channel_ids: [String],
|
||||
attachments: [Attachment],
|
||||
embeds: [Embed],
|
||||
reactions: [Reaction],
|
||||
nonce: Schema.Types.Mixed, // can be a long or a string
|
||||
pinned: Boolean,
|
||||
type: { type: Number },
|
||||
activity: {
|
||||
type: Number,
|
||||
party_id: String,
|
||||
},
|
||||
flags: Types.Long,
|
||||
stickers: [],
|
||||
message_reference: {
|
||||
message_id: String,
|
||||
channel_id: String,
|
||||
guild_id: String,
|
||||
},
|
||||
},
|
||||
});
|
||||
{
|
||||
toJSON: {
|
||||
transform: function (doc, ret) {
|
||||
delete ret.mention_channel_ids;
|
||||
delete ret.mention_user_ids;
|
||||
delete ret.mention_role_ids;
|
||||
},
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
MessageSchema.virtual("author", {
|
||||
ref: UserModel,
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
import mongoose from "mongoose";
|
||||
|
||||
export * from "./Ban";
|
||||
export * from "./Channel";
|
||||
export * from "./Emoji";
|
||||
export * from "./Guild";
|
||||
export * from "./Invite";
|
||||
export * from "./Member";
|
||||
export * from "./Role";
|
||||
export * from "./User";
|
||||
export * from "./Activity";
|
||||
export * from "./Application";
|
||||
export * from "./Interaction";
|
||||
export * from "./Message";
|
||||
export * from "./Status";
|
||||
export * from "./VoiceState";
|
||||
export * from "./Event";
|
||||
|
||||
mongoose.plugin((schema: any) => {
|
||||
schema.options.toJSON = {
|
||||
virtuals: true,
|
||||
versionKey: false,
|
||||
transform(doc: any, ret: any) {
|
||||
delete ret._id;
|
||||
delete ret.__v;
|
||||
},
|
||||
};
|
||||
});
|
||||
Reference in New Issue
Block a user