From fd32568e8ca6ca0f0e2198c9857fc7dd4d05acd0 Mon Sep 17 00:00:00 2001 From: Innei Date: Wed, 18 May 2022 22:40:22 +0800 Subject: [PATCH] refactor: extract note model --- src/modules/note/models/coordinate.model.ts | 13 +++++++++++++ src/modules/note/models/music.model.ts | 21 +++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 src/modules/note/models/coordinate.model.ts create mode 100644 src/modules/note/models/music.model.ts diff --git a/src/modules/note/models/coordinate.model.ts b/src/modules/note/models/coordinate.model.ts new file mode 100644 index 00000000..1622bbf9 --- /dev/null +++ b/src/modules/note/models/coordinate.model.ts @@ -0,0 +1,13 @@ +import { IsNumber } from 'class-validator' + +import { modelOptions, prop } from '@typegoose/typegoose' + +@modelOptions({ schemaOptions: { id: false, _id: false } }) +export class Coordinate { + @IsNumber() + @prop() + latitude: number + @prop() + @IsNumber() + longitude: number +} diff --git a/src/modules/note/models/music.model.ts b/src/modules/note/models/music.model.ts new file mode 100644 index 00000000..7522c53b --- /dev/null +++ b/src/modules/note/models/music.model.ts @@ -0,0 +1,21 @@ +import { IsNotEmpty, IsString } from 'class-validator' + +import { modelOptions, prop } from '@typegoose/typegoose' + +@modelOptions({ + schemaOptions: { + id: false, + _id: false, + }, +}) +export class NoteMusic { + @IsString() + @IsNotEmpty() + @prop({ required: true }) + type: string + + @IsString() + @IsNotEmpty() + @prop({ required: true }) + id: string +}