diff options
author | Dennis Eriksen <dennis.se@gmail.com> | 2013-04-29 12:51:38 +0200 |
---|---|---|
committer | Dennis Eriksen <dennis.se@gmail.com> | 2013-04-29 12:51:38 +0200 |
commit | 16f1f471c6a1ecb05a864d426f9137aa18289acb (patch) | |
tree | 458d2a1aeea00434a180ef1fa19adebfd63c1ef0 /models | |
parent | fixed missing use.css, changed text, removed hr line (diff) | |
download | Divid-16f1f471c6a1ecb05a864d426f9137aa18289acb.tar.gz |
fixed some models
Diffstat (limited to 'models')
-rw-r--r-- | models/project.js | 41 | ||||
-rw-r--r-- | models/system.js | 12 |
2 files changed, 53 insertions, 0 deletions
diff --git a/models/project.js b/models/project.js new file mode 100644 index 0000000..52853d7 --- /dev/null +++ b/models/project.js @@ -0,0 +1,41 @@ + +/** + * Module dependencies + */ + +var mongoose = require('mongoose') + , Schema = mongoose.Schema; + + + + + +var ProjectSchema = new Schema({ + user: { type: String, ref: 'User' }, + name: { type: String, default: '', trim: true }, + description: {type: String, default: '', trim: true }, + currency: { type: String, default: 'kr', trim: true }, + public: { type: String, default: 'invite-only' }, + created: { type: Date, default: Date.now }, + updated: { type: Date, default: Date.now } +}); + +console.log(Schema.ObjectId); + + +// the four validations below only apply if you are signing up traditionally + +ProjectSchema.path('name').validate(function(name) { + // if you're authenticated by any of the oauth strategies (facebook, twitter), don't validate + return name.length; +}, 'Project name cannot be blank'); + +ProjectSchema.methods = { + + log: function() { + console.log('wat. wat logged this'); + } + +} + +mongoose.model('Project', ProjectSchema); diff --git a/models/system.js b/models/system.js new file mode 100644 index 0000000..78d1361 --- /dev/null +++ b/models/system.js @@ -0,0 +1,12 @@ + +/** + * Module dependencies + */ + +var mongoose = require('mongoose') + , Schema = mongoose.Schema; + + + + + |