schema updates

semi-final schemas, i think
This commit is contained in:
oat 2020-09-04 16:47:10 +03:00
parent dc88ad2b75
commit 64446588c9
Signed by: oat
GPG key ID: DD83A9617A252385

View file

@ -1,39 +1,111 @@
/* eslint-disable no-unused-vars */
import * as mongoose from 'mongoose'; import * as mongoose from 'mongoose';
const Schema = mongoose.Schema; const Schema = mongoose.Schema;
export enum SMVersion {
OPENITG,
FUCKEXE,
NOTITG_V1,
NOTITG_V2,
NOTITG_V3,
NOTITG_V3_1,
NOTITG_V4,
NOTITG_V4_0_1,
STEPMANIA_3_95,
STEPMANIA_5_0,
STEPMANIA_5_1,
STEPMANIA_5_2,
STEPMANIA_5_3,
}
const Sample = new Schema({ const Sample = new Schema({
start: {type: Number, default: 0}, start: {type: Number, default: 0},
length: {type: Number, default: 0} length: {type: Number, default: 0}
}); });
const UserRating = new Schema({
rating: {type: Number, default: 0},
createdAt: Date,
user: {type: String, default: '00000000-0000-4000-a000-000000000000'}
});
const Chart = new Schema({ const Chart = new Schema({
type: {type: String, default: 'dance-single'}, type: {type: String, default: 'dance-single'},
name: {type: String, default: ''}, name: {type: String, default: ''},
difficulty: {type: String, default: 'Challenge'}, difficulty: {type: String, default: 'Challenge'},
radarvalues: [Number],
rating: {type: Number, default: 0}, rating: {type: Number, default: 0},
radarvalues: [Number] ratingsVote: {type: [UserRating], default: []},
spoilered: {type: Boolean, default: false},
hidden: {type: Boolean, default: false}
});
const Comment = new Schema({
author: {type: String, default: '00000000-0000-4000-a000-000000000000'},
createdAt: Date,
content: {type: String, default: ''}
}); });
const FileSchema = new Schema({ const FileSchema = new Schema({
id: {type: Number, default: 0},
title: {type: String, default: 'unknown'}, title: {type: String, default: 'unknown'},
titleTranslit: String, titleTranslit: String,
artist: {type: String, default: 'unknown'}, artist: {type: String, default: 'unknown'},
artistTranslit: String, artistTranslit: String,
subtitle: String, subtitle: String,
subtitleTranslit: String, subtitleTranslit: String,
credit: String, credit: String,
uploader: {type: String, default: '00000000-0000-4000-a000-000000000000'}, uploader: {type: String, default: '00000000-0000-4000-a000-000000000000'},
sample: Sample, sample: Sample,
bpms: {type: Object, default: {'0': 0}}, bpms: {type: Object, default: {'0': 0}},
charts: [Chart]
charts: {type: [Chart], default: []},
description: {type: String, default: ''},
createdAt: Date,
smVersion: {type: Number, default: 0}, // see SMVersion enum
ytLink: String,
customLink: String,
hidden: {type: Boolean, default: false},
comments: {type: [Comment], default: []},
}); });
export const File = mongoose.model('File', FileSchema); export const File = mongoose.model('File', FileSchema);
const UserSchema = new Schema({ // this is pretty much just a discord user lol const UserSchema = new Schema({ // this is pretty much just a discord user lol
id: String, // cus longass number id: String, // discord id, cus longass number
approved: Boolean createdAt: Number,
// caching
username: {type: String, default: 'User'},
discriminator: {type: String, default: '0000'},
avatar: String,
// used internally
uuid: {type: String, default: '00000000-0000-4000-a000-000000000000'},
approvedUpload: {type: Boolean, default: false},
approvedRate: {type: Boolean, default: false},
approvedComment: {type: Boolean, default: false},
}); });
export const User = mongoose.model('User', UserSchema); export const User = mongoose.model('User', UserSchema);
const PackSchema = new Schema({
author: {type: String, default: '00000000-0000-4000-a000-000000000000'},
files: {type: [Number], default: []}, // ids
name: {type: String, default: 'Pack'},
description: {type: String, default: ''},
createdAt: Date,
hidden: {type: Boolean, default: false},
});
export const Pack = mongoose.model('Pack', PackSchema);