Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add user model.

  • Loading branch information...
commit f33fb94505b63b936843197e5805d5dcb243ed63 1 parent 3f26dc2
@cmeiklejohn authored
Showing with 16 additions and 0 deletions.
  1. +16 −0 example-app/models/user.js
View
16 example-app/models/user.js
@@ -0,0 +1,16 @@
+var mongoose = require('mongoose');
+var db = mongoose.connect('mongodb://localhost:27017/example-app');
+var Schema = mongoose.Schema,
+ ObjectId = Schema.ObjectId;
+
+var User = new Schema({
+ id: ObjectId,
+ username: {
+ type: String,
+ index: true,
+ validate: [ function(o) { return u.length > 0 }, 'username is required.'],
+ }
+});
+
+mongoose.model('User', User);
+module.exports = db.model('User');
Please sign in to comment.
Something went wrong with that request. Please try again.