From 593159c22c2acad599b67d1b128a52232b79a34b Mon Sep 17 00:00:00 2001 From: eug-vs Date: Sat, 24 Apr 2021 20:34:00 +0300 Subject: feat: add accounts service --- src/models/account/account.model.ts | 4 ++++ src/models/account/account.schema.ts | 23 +++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 src/models/account/account.model.ts create mode 100644 src/models/account/account.schema.ts (limited to 'src/models') diff --git a/src/models/account/account.model.ts b/src/models/account/account.model.ts new file mode 100644 index 0000000..1df1406 --- /dev/null +++ b/src/models/account/account.model.ts @@ -0,0 +1,4 @@ +import { Model, model } from 'mongoose'; +import { AccountSchema, accountSchema } from './account.schema'; + +export default model>('Account', accountSchema); diff --git a/src/models/account/account.schema.ts b/src/models/account/account.schema.ts new file mode 100644 index 0000000..3ce3983 --- /dev/null +++ b/src/models/account/account.schema.ts @@ -0,0 +1,23 @@ +import { Document, Schema } from 'mongoose'; + +export interface AccountSchema extends Document { + name: string; + code: string; + balance: number; +} + +export const accountSchema = new Schema({ + name: { + type: String, + required: true, + }, + code: { + type: String, + required: true, + }, + balance: { + type: Number, + default: 0, + }, +}, { timestamps: true }); + -- cgit v1.2.3