summaryrefslogtreecommitdiff
path: root/src/models
diff options
context:
space:
mode:
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 });
+