mirror of
https://github.com/sstent/expressmongotest.git
synced 2026-02-07 23:11:50 +00:00
almost rebased
This commit is contained in:
22
chapter25/11_user_schema_with_enumerated_field.js
Normal file
22
chapter25/11_user_schema_with_enumerated_field.js
Normal file
@@ -0,0 +1,22 @@
|
||||
var mongoose = require('mongoose');
|
||||
|
||||
var emailRegexp = /.+\@.+\..+/;
|
||||
|
||||
var UserSchema = new mongoose.Schema({
|
||||
username: {type: String, unique: true},
|
||||
name: String,
|
||||
password: String,
|
||||
email: {
|
||||
type: String,
|
||||
required: true,
|
||||
match: emailRegexp
|
||||
},
|
||||
gender: {
|
||||
type: String,
|
||||
required: true,
|
||||
uppercase: true,
|
||||
'enum': ['M', 'F']
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = UserSchema;
|
||||
Reference in New Issue
Block a user