From 16f1f471c6a1ecb05a864d426f9137aa18289acb Mon Sep 17 00:00:00 2001 From: Dennis Eriksen Date: Mon, 29 Apr 2013 12:51:38 +0200 Subject: fixed some models --- models/project.js | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 models/project.js (limited to 'models/project.js') 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); -- cgit v1.2.3 From 7ffbad817125e0767ff51ae7b3ddd9092328bafc Mon Sep 17 00:00:00 2001 From: Dennis Eriksen Date: Mon, 29 Apr 2013 14:24:43 +0200 Subject: been working on the project model and posting projects --- models/project.js | 2 -- 1 file changed, 2 deletions(-) (limited to 'models/project.js') diff --git a/models/project.js b/models/project.js index 52853d7..2424694 100644 --- a/models/project.js +++ b/models/project.js @@ -20,8 +20,6 @@ var ProjectSchema = new Schema({ updated: { type: Date, default: Date.now } }); -console.log(Schema.ObjectId); - // the four validations below only apply if you are signing up traditionally -- cgit v1.2.3