38 lines
1.1 KiB
TypeScript
38 lines
1.1 KiB
TypeScript
import { BaseModule } from './Base'
|
|
import { dbconn } from '../decorators/dbconn'
|
|
import { getModelForClass, modelOptions, prop, Severity, mongoose, index } from '@typegoose/typegoose'
|
|
|
|
const jsonExcludeKeys = ['updatedAt', '__v', '_id', 'createdAt', 'isBot', 'type', 'inited']
|
|
|
|
@dbconn()
|
|
@index({ oldGameId: 1 }, { unique: true })
|
|
@modelOptions({
|
|
schemaOptions: { collection: 'jump_game_price_cache', timestamps: true },
|
|
options: { allowMixed: Severity.ALLOW },
|
|
})
|
|
class GamePriceCacheClass extends BaseModule {
|
|
@prop()
|
|
public oldGameId: string
|
|
@prop({ type: mongoose.Schema.Types.Mixed })
|
|
countries: any
|
|
@prop({ type: mongoose.Schema.Types.Mixed })
|
|
public prices: any
|
|
@prop({ default: true })
|
|
public inited: boolean
|
|
|
|
public toJson(): any {
|
|
let result: any = {}
|
|
// @ts-ignore
|
|
for (let key in this._doc) {
|
|
if (jsonExcludeKeys.indexOf(key) == -1) {
|
|
result[key] = this[key]
|
|
}
|
|
}
|
|
return result
|
|
}
|
|
}
|
|
|
|
export const GamePriceCache = getModelForClass(GamePriceCacheClass, {
|
|
existingConnection: GamePriceCacheClass.db,
|
|
})
|