mirror of
https://github.com/spacebarchat/server.git
synced 2026-10-20 19:02:48 +00:00
🐛 fix database
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { Schema, model, Types, Document } from "mongoose";
|
||||
import db from "../util/Database";
|
||||
|
||||
export interface AnyChannel extends Channel, DMChannel, TextChannel, VoiceChannel {}
|
||||
|
||||
@@ -31,7 +32,8 @@ export const ChannelSchema = new Schema({
|
||||
],
|
||||
});
|
||||
|
||||
export const ChannelModel = model<ChannelDocument>("Channel", ChannelSchema, "channels");
|
||||
// @ts-ignore
|
||||
export const ChannelModel = db.model<ChannelDocument>("Channel", ChannelSchema, "channels");
|
||||
|
||||
export interface Channel {
|
||||
id: bigint;
|
||||
|
||||
+3
-1
@@ -1,4 +1,5 @@
|
||||
import { Schema, model, Types, Document } from "mongoose";
|
||||
import db from "../util/Database";
|
||||
|
||||
export interface Emoji extends Document {
|
||||
id: bigint;
|
||||
@@ -24,4 +25,5 @@ export const EmojiSchema = new Schema({
|
||||
roles: [Types.Long],
|
||||
});
|
||||
|
||||
export const EmojiModel = model<Emoji>("Emoji", EmojiSchema, "emojis");
|
||||
// @ts-ignore
|
||||
export const EmojiModel = db.model<Emoji>("Emoji", EmojiSchema, "emojis");
|
||||
|
||||
+3
-1
@@ -11,6 +11,7 @@ import { VoiceState } from "./VoiceState";
|
||||
import { ApplicationCommand } from "./Application";
|
||||
import { Interaction } from "./Interaction";
|
||||
import { Schema, model, Types, Document } from "mongoose";
|
||||
import db from "../util/Database";
|
||||
|
||||
export interface Event {
|
||||
guild_id?: bigint;
|
||||
@@ -32,7 +33,8 @@ export const EventSchema = new Schema({
|
||||
data: Object,
|
||||
});
|
||||
|
||||
export const EventModel = model<EventDocument>("Event", EventSchema, "events");
|
||||
// @ts-ignore
|
||||
export const EventModel = db.model<EventDocument>("Event", EventSchema, "events");
|
||||
|
||||
// ! Custom Events that shouldn't get sent to the client but processed by the server
|
||||
|
||||
|
||||
+3
-1
@@ -1,4 +1,5 @@
|
||||
import { Schema, model, Types, Document } from "mongoose";
|
||||
import db from "../util/Database";
|
||||
|
||||
export interface GuildDocument extends Document, Guild {
|
||||
id: bigint;
|
||||
@@ -86,4 +87,5 @@ export const GuildSchema = new Schema({
|
||||
widget_enabled: Boolean,
|
||||
});
|
||||
|
||||
export const GuildModel = model<GuildDocument>("Guild", GuildSchema, "guilds");
|
||||
// @ts-ignore
|
||||
export const GuildModel = db.model<GuildDocument>("Guild", GuildSchema, "guilds");
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Schema, model, Types, Document } from "mongoose";
|
||||
import db from "../util/Database";
|
||||
|
||||
export interface Invite extends Document {
|
||||
code: string;
|
||||
@@ -73,4 +74,5 @@ export const InviteSchema = new Schema({
|
||||
target_user_type: Number,
|
||||
});
|
||||
|
||||
export const InviteModel = model<Invite>("Invite", InviteSchema, "invites");
|
||||
// @ts-ignore
|
||||
export const InviteModel = db.model<Invite>("Invite", InviteSchema, "invites");
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { PublicUser } from "./User";
|
||||
import { Schema, model, Types, Document } from "mongoose";
|
||||
import db from "../util/Database";
|
||||
|
||||
export interface Member {
|
||||
id: bigint;
|
||||
@@ -75,7 +76,8 @@ export const MemberSchema = new Schema({
|
||||
},
|
||||
});
|
||||
|
||||
export const MemberModel = model<MemberDocument>("Member", MemberSchema, "members");
|
||||
// @ts-ignore
|
||||
export const MemberModel = db.model<MemberDocument>("Member", MemberSchema, "members");
|
||||
|
||||
export interface PublicMember extends Omit<Member, "settings" | "id"> {
|
||||
user: PublicUser;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Schema, model, Types, Document } from "mongoose";
|
||||
import { ChannelType } from "./Channel";
|
||||
import db from "../util/Database";
|
||||
|
||||
export interface Message extends Document {
|
||||
id: bigint;
|
||||
@@ -227,4 +228,5 @@ export const MessageSchema = new Schema({
|
||||
},
|
||||
});
|
||||
|
||||
export const MessageModel = model<Message>("Message", MessageSchema, "messages");
|
||||
// @ts-ignore
|
||||
export const MessageModel = db.model<Message>("Message", MessageSchema, "messages");
|
||||
|
||||
+3
-1
@@ -1,4 +1,5 @@
|
||||
import { Schema, model, Types, Document } from "mongoose";
|
||||
import db from "../util/Database";
|
||||
|
||||
export interface Role {
|
||||
id: bigint;
|
||||
@@ -34,4 +35,5 @@ export const RoleSchema = new Schema({
|
||||
},
|
||||
});
|
||||
|
||||
export const RoleModel = model<RoleDocument>("Role", RoleSchema, "roles");
|
||||
// @ts-ignore
|
||||
export const RoleModel = db.model<RoleDocument>("Role", RoleSchema, "roles");
|
||||
|
||||
+3
-1
@@ -1,6 +1,7 @@
|
||||
import { Activity } from "./Activity";
|
||||
import { ClientStatus, Status } from "./Status";
|
||||
import { Schema, model, Types, Document } from "mongoose";
|
||||
import db from "../util/Database";
|
||||
|
||||
export interface User extends Document {
|
||||
id: bigint;
|
||||
@@ -202,4 +203,5 @@ export const UserSchema = new Schema({
|
||||
},
|
||||
});
|
||||
|
||||
export const UserModel = model<User>("User", UserSchema, "users");
|
||||
// @ts-ignore
|
||||
export const UserModel = db.model<User>("User", UserSchema, "users");
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { PublicMember } from "./Member";
|
||||
import { Schema, model, Types, Document } from "mongoose";
|
||||
import db from "../util/Database";
|
||||
|
||||
export interface VoiceState extends Document {
|
||||
guild_id?: bigint;
|
||||
@@ -29,4 +30,5 @@ export const VoiceSateSchema = new Schema({
|
||||
suppress: Boolean, // whether this user is muted by the current user
|
||||
});
|
||||
|
||||
export const VoiceStateModel = model<VoiceState>("VoiceState", VoiceSateSchema, "voicestates");
|
||||
// @ts-ignore
|
||||
export const VoiceStateModel = db.model<VoiceState>("VoiceState", VoiceSateSchema, "voicestates");
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
import "./MongoBigInt";
|
||||
import mongoose, { Collection } from "mongoose";
|
||||
import mongoose, { Collection, Connection } from "mongoose";
|
||||
import { ChangeStream, ChangeEvent, Long } from "mongodb";
|
||||
import EventEmitter from "events";
|
||||
const uri = process.env.MONGO_URL || "mongodb://localhost:27017/fosscord?readPreference=secondaryPreferred";
|
||||
|
||||
export default mongoose.connection;
|
||||
const connection = mongoose.createConnection(uri, { autoIndex: true });
|
||||
|
||||
export default <Connection>connection;
|
||||
|
||||
export interface MongooseCache {
|
||||
on(event: "delete", listener: (id: string) => void): this;
|
||||
|
||||
Reference in New Issue
Block a user