使い方
enumはString型に指定する。
バリデーションの設定なので、ここで設定された値以外を入れようとするとエラーになるらしい。
var userSchema = mongoose.Schema({
uid : { type: String, required:true, index: {unique:true} },
name: { first: String, last: String },
age : { type: Number, min: 1 },
gender : { type: String, enum: ['male', 'female', 'neuter'] }
});
参考
Mongoose学習#1「とりあえず使えるレベル」
http://yone-public.blogspot.jp/2012/11/mongoose1.html
If I never try, I'll never know: Node.jsが面白い件④ MongoDBで遊ぶ 〜Mongoose編その①〜
http://intink.blogspot.jp/2012/12/nodejs-mongodb-mongoose.html
Mongoose Validation v3.8.23
http://mongoosejs.com/docs/validation.html
Mongoose ODM
http://mongoosejs.com/docs/2.7.x/docs/schematypes.html