Created
March 5, 2020 15:30
-
-
Save bogoslavskiy/ff94d7bd66dcae745e43a453106b369f to your computer and use it in GitHub Desktop.
This file contains hidden or 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'; | |
function timestamp() { | |
return +new Date(); | |
} | |
export interface MessageDocument extends mongoose.Document { | |
sender_id: string; | |
senderName: string; | |
text: string; | |
date: number; | |
} | |
const schema = new mongoose.Schema<MessageDocument>( | |
{ | |
sender_id: { | |
type: String, | |
required: true, | |
}, | |
senderName: { | |
type: String, | |
required: true, | |
}, | |
text: { | |
type: String, | |
required: true, | |
}, | |
date: { | |
type: Number, | |
default: timestamp | |
} | |
}, | |
{ versionKey: false } | |
); | |
export default mongoose.model<MessageDocument>('Message', schema); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment