Created
February 19, 2020 12:40
-
-
Save mikeyakymenko/35ed82625d1157d8235264c551bead65 to your computer and use it in GitHub Desktop.
Models
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as mongoose from 'mongoose' | |
import {AdressDbModel} from './types' | |
const adressSchema = new mongoose.Schema({ | |
country: { | |
type: String, | |
required: true | |
}, | |
city: { | |
type: String, | |
required: true | |
}, | |
streetAdress: { | |
type: String, | |
required: true | |
}, | |
state: { | |
type: String, | |
required: true | |
}, | |
postal: { | |
type: String, | |
required: true | |
}, | |
user: { | |
type: mongoose.Schema.Types.ObjectId, | |
ref: 'User' | |
} | |
}, { | |
timestamps: true, | |
versionKey: false | |
}) | |
const Adress = mongoose.model<AdressDbModel>('User', adressSchema) | |
export default Adress |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Document from 'mongoose' | |
import {UserDbModel} from 'controllers/users/types' | |
type AdressModel = { | |
сountry: string | |
city: string | |
streetAdress: string | |
state: string | |
postal: string | |
user: UserDbModel['_id'] | |
} | |
type AdressDbModel = AdressModel & Document | |
export {AdressDbModel} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment