From d556ef525f593ccb8c688e340f70659849ac74a3 Mon Sep 17 00:00:00 2001 From: Dennis Eriksen Date: Tue, 30 Apr 2013 14:41:30 +0200 Subject: renamed files to match model names --- models/project.js | 67 ------------------------------------------------------- 1 file changed, 67 deletions(-) delete mode 100644 models/project.js (limited to 'models/project.js') diff --git a/models/project.js b/models/project.js deleted file mode 100644 index f29c7f8..0000000 --- a/models/project.js +++ /dev/null @@ -1,67 +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 = { - - log: function() { - console.log('wat. wat logged this'); - }, - - - - /** - * Find project by id - * - * @param {ObjectId} id - * @param {Function} callback - * @api private - */ - - load: function(id, callback) { - this.findOne({ _id: id }) - .populate('user') - .exec(callback); - } - - -} - -mongoose.model('Project', ProjectSchema); -- cgit v1.2.3