🏷️ added interfaces for schemas
This commit is contained in:
parent
7562d039e4
commit
cb55c3f128
4 changed files with 59 additions and 28 deletions
|
@ -1,15 +1,22 @@
|
|||
import mongoose from "mongoose";
|
||||
import { Snowflake } from "discord.js";
|
||||
import { model, Schema } from "mongoose";
|
||||
|
||||
const apiSchema = new mongoose.Schema(
|
||||
export interface IApi {
|
||||
guildId: Snowflake;
|
||||
url: string;
|
||||
token: { iv: string; content: string };
|
||||
}
|
||||
|
||||
const apiSchema = new Schema<IApi>(
|
||||
{
|
||||
guildId: {
|
||||
type: mongoose.SchemaTypes.Decimal128,
|
||||
type: String,
|
||||
required: true,
|
||||
unique: false,
|
||||
index: true,
|
||||
},
|
||||
url: {
|
||||
type: mongoose.SchemaTypes.String,
|
||||
type: String,
|
||||
required: true,
|
||||
unique: false,
|
||||
index: true,
|
||||
|
@ -17,14 +24,14 @@ const apiSchema = new mongoose.Schema(
|
|||
},
|
||||
token: {
|
||||
iv: {
|
||||
type: mongoose.SchemaTypes.String,
|
||||
type: String,
|
||||
required: true,
|
||||
unique: false,
|
||||
index: true,
|
||||
default: "token",
|
||||
},
|
||||
content: {
|
||||
type: mongoose.SchemaTypes.String,
|
||||
type: String,
|
||||
required: true,
|
||||
unique: false,
|
||||
index: true,
|
||||
|
@ -35,4 +42,4 @@ const apiSchema = new mongoose.Schema(
|
|||
{ timestamps: true }
|
||||
);
|
||||
|
||||
export default mongoose.model("api", apiSchema);
|
||||
export default model<IApi>("api", apiSchema);
|
||||
|
|
|
@ -1,27 +1,35 @@
|
|||
import mongoose from "mongoose";
|
||||
import { Schema, model } from "mongoose";
|
||||
import { Snowflake } from "discord.js";
|
||||
|
||||
const counterSchema = new mongoose.Schema(
|
||||
export interface ICounter {
|
||||
guildId: Snowflake;
|
||||
channelId: Snowflake;
|
||||
word: string;
|
||||
counter: number;
|
||||
}
|
||||
|
||||
const counterSchema = new Schema<ICounter>(
|
||||
{
|
||||
guildId: {
|
||||
type: mongoose.SchemaTypes.Decimal128,
|
||||
type: String,
|
||||
required: true,
|
||||
unique: false,
|
||||
index: true,
|
||||
},
|
||||
channelId: {
|
||||
type: mongoose.SchemaTypes.String,
|
||||
type: String,
|
||||
required: true,
|
||||
unique: true,
|
||||
index: true,
|
||||
},
|
||||
word: {
|
||||
type: mongoose.SchemaTypes.String,
|
||||
type: String,
|
||||
required: true,
|
||||
unique: false,
|
||||
index: true,
|
||||
},
|
||||
counter: {
|
||||
type: mongoose.SchemaTypes.Number,
|
||||
type: Number,
|
||||
required: true,
|
||||
unique: false,
|
||||
index: true,
|
||||
|
@ -31,4 +39,4 @@ const counterSchema = new mongoose.Schema(
|
|||
{ timestamps: true }
|
||||
);
|
||||
|
||||
export default mongoose.model("counter", counterSchema);
|
||||
export default model<ICounter>("counter", counterSchema);
|
||||
|
|
|
@ -1,34 +1,43 @@
|
|||
import mongoose from "mongoose";
|
||||
import { Snowflake } from "discord.js";
|
||||
import { Schema, model } from "mongoose";
|
||||
|
||||
const shopRoleSchema = new mongoose.Schema(
|
||||
export interface IShopRole {
|
||||
roleId: Snowflake;
|
||||
userId: Snowflake;
|
||||
guildId: Snowflake;
|
||||
pricePerHour: number;
|
||||
lastPayed: Date;
|
||||
}
|
||||
|
||||
const shopRoleSchema = new Schema<IShopRole>(
|
||||
{
|
||||
roleId: {
|
||||
type: mongoose.SchemaTypes.Decimal128,
|
||||
type: String,
|
||||
required: true,
|
||||
unique: false,
|
||||
index: true,
|
||||
},
|
||||
userId: {
|
||||
type: mongoose.SchemaTypes.Decimal128,
|
||||
type: String,
|
||||
required: true,
|
||||
unique: false,
|
||||
index: true,
|
||||
},
|
||||
guildId: {
|
||||
type: mongoose.SchemaTypes.Decimal128,
|
||||
type: String,
|
||||
required: true,
|
||||
unique: false,
|
||||
index: true,
|
||||
},
|
||||
pricePerHour: {
|
||||
type: mongoose.SchemaTypes.Number,
|
||||
type: Number,
|
||||
required: true,
|
||||
unique: false,
|
||||
index: true,
|
||||
default: 5,
|
||||
},
|
||||
lastPayed: {
|
||||
type: mongoose.SchemaTypes.Date,
|
||||
type: Date,
|
||||
unique: false,
|
||||
index: true,
|
||||
},
|
||||
|
@ -36,4 +45,4 @@ const shopRoleSchema = new mongoose.Schema(
|
|||
{ timestamps: true }
|
||||
);
|
||||
|
||||
export default mongoose.model("shopRole", shopRoleSchema);
|
||||
export default model<IShopRole>("shopRole", shopRoleSchema);
|
||||
|
|
|
@ -1,22 +1,29 @@
|
|||
import mongoose from "mongoose";
|
||||
import { Snowflake } from "discord.js";
|
||||
import { Schema, model } from "mongoose";
|
||||
|
||||
const timeoutSchema = new mongoose.Schema(
|
||||
export interface ITimeout {
|
||||
userId: Snowflake;
|
||||
guildId: Snowflake;
|
||||
timeoutId: string;
|
||||
}
|
||||
|
||||
const timeoutSchema = new Schema<ITimeout>(
|
||||
{
|
||||
userId: {
|
||||
type: mongoose.SchemaTypes.Decimal128,
|
||||
type: String,
|
||||
required: true,
|
||||
unique: false,
|
||||
index: true,
|
||||
},
|
||||
guildId: {
|
||||
type: mongoose.SchemaTypes.Decimal128,
|
||||
type: String,
|
||||
required: true,
|
||||
unique: false,
|
||||
index: true,
|
||||
},
|
||||
timeoutId: { type: mongoose.SchemaTypes.String },
|
||||
timeoutId: { type: String },
|
||||
},
|
||||
{ timestamps: true }
|
||||
);
|
||||
|
||||
export default mongoose.model("timeout", timeoutSchema);
|
||||
export default model<ITimeout>("timeout", timeoutSchema);
|
||||
|
|
Loading…
Add table
Reference in a new issue