aboutsummaryrefslogtreecommitdiff
path: root/models/users
diff options
context:
space:
mode:
authoreug-vs <eug-vs@keemail.me>2020-06-09 19:23:44 +0300
committereug-vs <eug-vs@keemail.me>2020-06-09 19:23:44 +0300
commitde9771959850f193f173616b73099c3ae6f010c9 (patch)
tree65262d9badbc46f99d8644705c4aeed62e5373ca /models/users
parent39d637a817460ee62a0a6667abd6afc5b6898895 (diff)
downloadwhich-api-de9771959850f193f173616b73099c3ae6f010c9.tar.gz
feat!: integrate mongoDB
Diffstat (limited to 'models/users')
-rw-r--r--models/users/user.model.ts5
-rw-r--r--models/users/user.schema.ts19
2 files changed, 24 insertions, 0 deletions
diff --git a/models/users/user.model.ts b/models/users/user.model.ts
new file mode 100644
index 0000000..cec9298
--- /dev/null
+++ b/models/users/user.model.ts
@@ -0,0 +1,5 @@
+import { Model, model } from "mongoose"
+import { User, UserSchema } from './user.schema';
+
+export default model<User, Model<User>>("User", UserSchema);
+
diff --git a/models/users/user.schema.ts b/models/users/user.schema.ts
new file mode 100644
index 0000000..c846f81
--- /dev/null
+++ b/models/users/user.schema.ts
@@ -0,0 +1,19 @@
+import { Document, Schema } from "mongoose"
+
+export interface User extends Document {
+ name: string;
+ avatarUrl?: string;
+ age?: number;
+}
+
+export const UserSchema = new Schema({
+ name: String,
+ avatarUrl: {
+ type: String,
+ required: false
+ },
+ age: {
+ type: Number
+ }
+});
+