From b9ebe73eaaa6f82423a965a496573c65d7471f9e Mon Sep 17 00:00:00 2001 From: Matthew R Date: Tue, 29 Sep 2020 02:43:48 -0400 Subject: [PATCH] Add merchant model --- src/class/Client.ts | 6 +++--- src/models/Merchant.ts | 20 ++++++++++++++++++++ src/models/index.ts | 1 + 3 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 src/models/Merchant.ts diff --git a/src/class/Client.ts b/src/class/Client.ts index 4fe7ff4..6b031c9 100644 --- a/src/class/Client.ts +++ b/src/class/Client.ts @@ -3,7 +3,7 @@ import pluris from 'pluris'; import mongoose from 'mongoose'; import { promises as fs } from 'fs'; import { Collection, Command, LocalStorage, Util, ServerManagement, Event } from '.'; -import { File, FileInterface, Member, MemberInterface, Moderation, ModerationInterface, NNTrainingData, NNTrainingDataInterface, Note, NoteInterface, PagerNumber, PagerNumberInterface, Rank, RankInterface, Redirect, RedirectInterface, Score, ScoreInterface, Staff, StaffInterface, Stat, StatInterface } from '../models'; +import { File, FileInterface, Member, MemberInterface, Merchant, MerchantInterface, Moderation, ModerationInterface, NNTrainingData, NNTrainingDataInterface, Note, NoteInterface, PagerNumber, PagerNumberInterface, Rank, RankInterface, Redirect, RedirectInterface, Score, ScoreInterface, Staff, StaffInterface, Stat, StatInterface } from '../models'; import { Config } from '../../types'; // eslint-disable-line pluris(eris); @@ -21,14 +21,14 @@ export default class Client extends eris.Client { public serverManagement: ServerManagement; - public db: { File: mongoose.Model, Member: mongoose.Model, Moderation: mongoose.Model, NNTrainingData: mongoose.Model, Note: mongoose.Model, PagerNumber: mongoose.Model, Rank: mongoose.Model, Redirect: mongoose.Model, Score: mongoose.Model, Staff: mongoose.Model, Stat: mongoose.Model, local: { muted: LocalStorage } }; + public db: { File: mongoose.Model, Member: mongoose.Model, Merchant: mongoose.Model, Moderation: mongoose.Model, NNTrainingData: mongoose.Model, Note: mongoose.Model, PagerNumber: mongoose.Model, Rank: mongoose.Model, Redirect: mongoose.Model, Score: mongoose.Model, Staff: mongoose.Model, Stat: mongoose.Model, local: { muted: LocalStorage } }; constructor(token: string, options?: eris.ClientOptions) { super(token, options); this.commands = new Collection(); this.events = new Collection(); this.intervals = new Collection(); - this.db = { File, Member, Moderation, NNTrainingData, Note, PagerNumber, Rank, Redirect, Score, Staff, Stat, local: { muted: new LocalStorage('muted') } }; + this.db = { File, Member, Merchant, Moderation, NNTrainingData, Note, PagerNumber, Rank, Redirect, Score, Staff, Stat, local: { muted: new LocalStorage('muted') } }; } public async loadDatabase() { diff --git a/src/models/Merchant.ts b/src/models/Merchant.ts new file mode 100644 index 0000000..6c26d9b --- /dev/null +++ b/src/models/Merchant.ts @@ -0,0 +1,20 @@ +import { Document, Schema, model } from 'mongoose'; + +export interface MerchantInterface extends Document { + name: string, + key: string, + /** + * type + * - 0: hard + * - 1: soft + */ + pulls: [{ type: 0 | 1, reason: string, date: Date }], +} + +const Merchant: Schema = new Schema({ + name: String, + key: String, + pulls: Array, +}); + +export default model('Merchant', Merchant); diff --git a/src/models/index.ts b/src/models/index.ts index b3ef0e7..dbf39a8 100644 --- a/src/models/index.ts +++ b/src/models/index.ts @@ -1,5 +1,6 @@ export { default as File, FileInterface } from './File'; export { default as Member, MemberInterface } from './Member'; +export { default as Merchant, MerchantInterface } from './Merchant'; export { default as Moderation, ModerationInterface } from './Moderation'; export { default as NNTrainingData, NNTrainingDataInterface } from './NNTrainingData'; export { default as Note, NoteInterface } from './Note';