Skip to content

Instantly share code, notes, and snippets.

@nahakyuu
Created January 18, 2016 08:32
Show Gist options
  • Save nahakyuu/56beec24fbab569deca5 to your computer and use it in GitHub Desktop.
Save nahakyuu/56beec24fbab569deca5 to your computer and use it in GitHub Desktop.
Typescript mongoose
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