summaryrefslogtreecommitdiff
path: root/src/models
diff options
context:
space:
mode:
authoreug-vs <eug-vs@keemail.me>2021-03-19 23:57:18 +0300
committereug-vs <eug-vs@keemail.me>2021-03-19 23:57:18 +0300
commitad530510a4aba72f3074f1a7dec82cc9018db7b4 (patch)
tree5f684dce9eee4b67f18f20864bc26d83a3a4a075 /src/models
parent3109e25f2cabb85bbccf4ba509e112e49f5c0120 (diff)
downloadcommercel-api-ad530510a4aba72f3074f1a7dec82cc9018db7b4.tar.gz
feat: add Transfers service
Diffstat (limited to 'src/models')
-rw-r--r--src/models/transfer/transfer.model.ts4
-rw-r--r--src/models/transfer/transfer.schema.ts29
2 files changed, 33 insertions, 0 deletions
diff --git a/src/models/transfer/transfer.model.ts b/src/models/transfer/transfer.model.ts
new file mode 100644
index 0000000..29f5b0d
--- /dev/null
+++ b/src/models/transfer/transfer.model.ts
@@ -0,0 +1,4 @@
+import { Model, model } from 'mongoose';
+import { TransferSchema, transferSchema } from './transfer.schema';
+
+export default model<TransferSchema, Model<TransferSchema>>('Transfer', transferSchema);
diff --git a/src/models/transfer/transfer.schema.ts b/src/models/transfer/transfer.schema.ts
new file mode 100644
index 0000000..ebdb6ab
--- /dev/null
+++ b/src/models/transfer/transfer.schema.ts
@@ -0,0 +1,29 @@
+import { Document, Schema, Types } from 'mongoose';
+
+export interface TransferSchema extends Document {
+ date: string;
+ operation: 'in' | 'out';
+ contractorId: string;
+ amount: number;
+}
+
+
+export const transferSchema = new Schema({
+ date: {
+ type: Date,
+ required: true,
+ },
+ operation: {
+ type: String,
+ required: true,
+ },
+ contractorId: {
+ type: Types.ObjectId,
+ required: true,
+ },
+ amount: {
+ type: Number,
+ required: true,
+ },
+}, { timestamps: true });
+