in-the-database-2/src/schema.ts

31 lines
838 B
TypeScript

import * as mongoose from 'mongoose';
const Schema = mongoose.Schema;
const Int32 = require('mongoose-int32');
const Sample = new Schema({
start: {type: Int32, default: new Int32(0)},
length: {type: Int32, default: new Int32(0)}
});
const Chart = new Schema({
name: {type: String, default: ''},
rating: {type: Int32, default: new Int32(0)},
type: {type: String, default: 'Challenge'}
});
const FileSchema = new Schema({
title: {type: String, default: 'unknown'},
titleTranslit: String,
artist: {type: String, default: 'unknown'},
artistTranslit: String,
subtitle: String,
subtitleTranslit: String,
credit: String,
uploader: {type: String, default: '00000000-0000-4000-a000-000000000000'},
sample: Sample,
bpms: {type: [Number], default: 0},
charts: [Chart]
});
export const File = mongoose.model('File', FileSchema);