aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/models/project.js
blob: 52853d7ff1e2e43ba9b87237100d969a0445fee6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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);