aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/models/Project.js
diff options
context:
space:
mode:
authorDennis Eriksen <dennis.se@gmail.com>2013-05-25 11:17:42 +0200
committerDennis Eriksen <dennis.se@gmail.com>2013-05-25 11:17:42 +0200
commite582c3b84c6090b08f33d599c354968fcd868d14 (patch)
treeb6de1b7b1f708bf9126ccb709d5129e91a67c7d5 /models/Project.js
parentchanged what gets collected (diff)
downloadDivid-e582c3b84c6090b08f33d599c354968fcd868d14.tar.gz
moved and renamed files to match the filesetup we want.
havebeen using a dev-setup till now.
Diffstat (limited to 'models/Project.js')
-rw-r--r--models/Project.js75
1 files changed, 0 insertions, 75 deletions
diff --git a/models/Project.js b/models/Project.js
deleted file mode 100644
index ba0e8e7..0000000
--- a/models/Project.js
+++ /dev/null
@@ -1,75 +0,0 @@
-
-/**
- * Module dependencies
- */
-
-var mongoose = require('mongoose')
- , Schema = mongoose.Schema;
-
-var ProjectSchema = new Schema({
- user: { type: Schema.ObjectId, 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 },
- shortURL: { type: String, unique: true }
-});
-
-// 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.pre('save', function(next) {
- if (this.shortURL !== undefined) return next();
- var chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
- this.shortURL = '';
- for (var i = 0; i < 6; i++) {
- var x = Math.floor(Math.random() * chars.length);
- this.shortURL += chars.charAt(x);
- }
- console.log('SHORT: ' + this.shortURL);
- next();
-});
-
-
-
-ProjectSchema.statics = {
-
- /**
- * Find project by id
- *
- * @param {ObjectId} id
- * @param {Function} callback
- * @api private
- */
-
- load: function(id, callback) {
- this.findOne({ _id: id })
- .populate('user')
- .exec(callback);
- },
-
-
- /**
- * Find project my shortURL
- *
- * @param {shortURL} shortURL
- * @param {Function} callback
- * @api private
- */
-
- loadShort : function(shortURL, callback) {
- this.findOne({ shortURL: shortURL })
- .populate('user')
- .exec(callback);
- }
-
-}
-
-mongoose.model('Project', ProjectSchema);