diff options
author | eug-vs <eug-vs@keemail.me> | 2020-06-09 19:23:44 +0300 |
---|---|---|
committer | eug-vs <eug-vs@keemail.me> | 2020-06-09 19:23:44 +0300 |
commit | de9771959850f193f173616b73099c3ae6f010c9 (patch) | |
tree | 65262d9badbc46f99d8644705c4aeed62e5373ca /models/users | |
parent | 39d637a817460ee62a0a6667abd6afc5b6898895 (diff) | |
download | which-api-de9771959850f193f173616b73099c3ae6f010c9.tar.gz |
feat!: integrate mongoDB
Diffstat (limited to 'models/users')
-rw-r--r-- | models/users/user.model.ts | 5 | ||||
-rw-r--r-- | models/users/user.schema.ts | 19 |
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 + } +}); + |