Created
January 18, 2016 08:32
-
-
Save nahakyuu/56beec24fbab569deca5 to your computer and use it in GitHub Desktop.
Typescript mongoose
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 Schema = mongoose.Schema; | |
import Document = mongoose.Document; | |
var UserSchema = new Schema({ | |
name: String, | |
password: String, | |
email: String, | |
head: String | |
}); | |
// IUser只是单纯用来约束类型的,并没有什么作用 | |
export interface IUser extends Document { | |
name: string; | |
password: string; | |
email: string; | |
head: string; | |
} | |
export var User = mongoose.model<IUser>("users", UserSchema); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment