aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/models
diff options
context:
space:
mode:
authorLurifax <stianalexanderolsen@gmail.com>2013-04-29 14:49:39 +0200
committerLurifax <stianalexanderolsen@gmail.com>2013-04-29 14:49:39 +0200
commite0a8e93d0e691c3939a121f65e87dece50f6d97d (patch)
tree263cd285ca4b06c7c13cc6f92e3cf7739be9bfc1 /models
parentMerge branch 'master' of github.com:dennisse/Divid (diff)
parentbeen working on the project model and posting projects (diff)
downloadDivid-e0a8e93d0e691c3939a121f65e87dece50f6d97d.tar.gz
Merge branch 'master' of github.com:dennisse/Divid
Diffstat (limited to 'models')
-rw-r--r--models/project.js39
1 files changed, 39 insertions, 0 deletions
diff --git a/models/project.js b/models/project.js
new file mode 100644
index 0000000..2424694
--- /dev/null
+++ b/models/project.js
@@ -0,0 +1,39 @@
+
+/**
+ * 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 }
+});
+
+
+// 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);