🏷️ 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: {
|
guildId: {
|
||||||
type: mongoose.SchemaTypes.Decimal128,
|
type: String,
|
||||||
required: true,
|
required: true,
|
||||||
unique: false,
|
unique: false,
|
||||||
index: true,
|
index: true,
|
||||||
},
|
},
|
||||||
url: {
|
url: {
|
||||||
type: mongoose.SchemaTypes.String,
|
type: String,
|
||||||
required: true,
|
required: true,
|
||||||
unique: false,
|
unique: false,
|
||||||
index: true,
|
index: true,
|
||||||
|
@ -17,14 +24,14 @@ const apiSchema = new mongoose.Schema(
|
||||||
},
|
},
|
||||||
token: {
|
token: {
|
||||||
iv: {
|
iv: {
|
||||||
type: mongoose.SchemaTypes.String,
|
type: String,
|
||||||
required: true,
|
required: true,
|
||||||
unique: false,
|
unique: false,
|
||||||
index: true,
|
index: true,
|
||||||
default: "token",
|
default: "token",
|
||||||
},
|
},
|
||||||
content: {
|
content: {
|
||||||
type: mongoose.SchemaTypes.String,
|
type: String,
|
||||||
required: true,
|
required: true,
|
||||||
unique: false,
|
unique: false,
|
||||||
index: true,
|
index: true,
|
||||||
|
@ -35,4 +42,4 @@ const apiSchema = new mongoose.Schema(
|
||||||
{ timestamps: true }
|
{ 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: {
|
guildId: {
|
||||||
type: mongoose.SchemaTypes.Decimal128,
|
type: String,
|
||||||
required: true,
|
required: true,
|
||||||
unique: false,
|
unique: false,
|
||||||
index: true,
|
index: true,
|
||||||
},
|
},
|
||||||
channelId: {
|
channelId: {
|
||||||
type: mongoose.SchemaTypes.String,
|
type: String,
|
||||||
required: true,
|
required: true,
|
||||||
unique: true,
|
unique: true,
|
||||||
index: true,
|
index: true,
|
||||||
},
|
},
|
||||||
word: {
|
word: {
|
||||||
type: mongoose.SchemaTypes.String,
|
type: String,
|
||||||
required: true,
|
required: true,
|
||||||
unique: false,
|
unique: false,
|
||||||
index: true,
|
index: true,
|
||||||
},
|
},
|
||||||
counter: {
|
counter: {
|
||||||
type: mongoose.SchemaTypes.Number,
|
type: Number,
|
||||||
required: true,
|
required: true,
|
||||||
unique: false,
|
unique: false,
|
||||||
index: true,
|
index: true,
|
||||||
|
@ -31,4 +39,4 @@ const counterSchema = new mongoose.Schema(
|
||||||
{ timestamps: true }
|
{ 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: {
|
roleId: {
|
||||||
type: mongoose.SchemaTypes.Decimal128,
|
type: String,
|
||||||
required: true,
|
required: true,
|
||||||
unique: false,
|
unique: false,
|
||||||
index: true,
|
index: true,
|
||||||
},
|
},
|
||||||
userId: {
|
userId: {
|
||||||
type: mongoose.SchemaTypes.Decimal128,
|
type: String,
|
||||||
required: true,
|
required: true,
|
||||||
unique: false,
|
unique: false,
|
||||||
index: true,
|
index: true,
|
||||||
},
|
},
|
||||||
guildId: {
|
guildId: {
|
||||||
type: mongoose.SchemaTypes.Decimal128,
|
type: String,
|
||||||
required: true,
|
required: true,
|
||||||
unique: false,
|
unique: false,
|
||||||
index: true,
|
index: true,
|
||||||
},
|
},
|
||||||
pricePerHour: {
|
pricePerHour: {
|
||||||
type: mongoose.SchemaTypes.Number,
|
type: Number,
|
||||||
required: true,
|
required: true,
|
||||||
unique: false,
|
unique: false,
|
||||||
index: true,
|
index: true,
|
||||||
default: 5,
|
default: 5,
|
||||||
},
|
},
|
||||||
lastPayed: {
|
lastPayed: {
|
||||||
type: mongoose.SchemaTypes.Date,
|
type: Date,
|
||||||
unique: false,
|
unique: false,
|
||||||
index: true,
|
index: true,
|
||||||
},
|
},
|
||||||
|
@ -36,4 +45,4 @@ const shopRoleSchema = new mongoose.Schema(
|
||||||
{ timestamps: true }
|
{ 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: {
|
userId: {
|
||||||
type: mongoose.SchemaTypes.Decimal128,
|
type: String,
|
||||||
required: true,
|
required: true,
|
||||||
unique: false,
|
unique: false,
|
||||||
index: true,
|
index: true,
|
||||||
},
|
},
|
||||||
guildId: {
|
guildId: {
|
||||||
type: mongoose.SchemaTypes.Decimal128,
|
type: String,
|
||||||
required: true,
|
required: true,
|
||||||
unique: false,
|
unique: false,
|
||||||
index: true,
|
index: true,
|
||||||
},
|
},
|
||||||
timeoutId: { type: mongoose.SchemaTypes.String },
|
timeoutId: { type: String },
|
||||||
},
|
},
|
||||||
{ timestamps: true }
|
{ timestamps: true }
|
||||||
);
|
);
|
||||||
|
|
||||||
export default mongoose.model("timeout", timeoutSchema);
|
export default model<ITimeout>("timeout", timeoutSchema);
|
||||||
|
|
Loading…
Add table
Reference in a new issue