mirror of
https://github.com/spacebarchat/server.git
synced 2024-11-11 13:14:06 +01:00
✨ [Message] Model add created_at
This commit is contained in:
parent
8cf9ca4898
commit
31023ffa68
@ -1,9 +1,10 @@
|
|||||||
import { Schema, Types, Document } from "mongoose";
|
import { Schema, Types, Document } from "mongoose";
|
||||||
import db from "../util/Database";
|
import db from "../util/Database";
|
||||||
import { PublicUser, PublicUserProjection, UserModel } from "./User";
|
import { PublicUser, PublicUserProjection, UserModel } from "./User";
|
||||||
import { MemberModel, PublicMember, PublicMemberProjection } from "./Member";
|
import { MemberModel, PublicMember } from "./Member";
|
||||||
import { Role, RoleModel } from "./Role";
|
import { Role, RoleModel } from "./Role";
|
||||||
import { Channel } from "./Channel";
|
import { Channel } from "./Channel";
|
||||||
|
import { Snowflake } from "../util";
|
||||||
|
|
||||||
export interface Message {
|
export interface Message {
|
||||||
id: string;
|
id: string;
|
||||||
@ -45,6 +46,7 @@ export interface Message {
|
|||||||
})[];
|
})[];
|
||||||
mention_roles?: Role[];
|
mention_roles?: Role[];
|
||||||
mention_channels?: Channel[];
|
mention_channels?: Channel[];
|
||||||
|
created_at: Date;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MessageDocument extends Document, Message {
|
export interface MessageDocument extends Document, Message {
|
||||||
@ -280,6 +282,10 @@ MessageSchema.virtual("mention_channels", {
|
|||||||
autopopulate: { select: { id: true, guild_id: true, type: true, name: true } },
|
autopopulate: { select: { id: true, guild_id: true, type: true, name: true } },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
MessageSchema.virtual("created_at").get(function (this: MessageDocument) {
|
||||||
|
return new Date(Snowflake.deconstruct(this.id).timestamp);
|
||||||
|
});
|
||||||
|
|
||||||
MessageSchema.set("removeResponse", ["mention_channel_ids", "mention_role_ids", "mention_user_ids", "author_id"]);
|
MessageSchema.set("removeResponse", ["mention_channel_ids", "mention_role_ids", "mention_user_ids", "author_id"]);
|
||||||
|
|
||||||
// TODO: missing Application Model
|
// TODO: missing Application Model
|
||||||
|
Loading…
Reference in New Issue
Block a user