Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 27 lines (21 sloc) 0.707 kb
969876a @visnup start directing to team creation
visnup authored
1 _ = require 'underscore'
2ffa112 @visnup got teams to actually save
visnup authored
2 mongoose = require 'mongoose'
3 ObjectId = mongoose.Schema.ObjectId
4 Invite = require './invite'
5
969876a @visnup start directing to team creation
visnup authored
6 TeamSchema = new mongoose.Schema
2ffa112 @visnup got teams to actually save
visnup authored
7 name:
8 type: String
d81de42 @visnup include timestamps
visnup authored
9 validate: [ /./, "Name can't be blank" ]
10 emails: [ String ]
11 invites: [ Invite ]
12 people_ids: [ ObjectId ]
13 TeamSchema.plugin require('mongoose-types').useTimestamps
2ffa112 @visnup got teams to actually save
visnup authored
14
969876a @visnup start directing to team creation
visnup authored
15 TeamSchema.path('emails').validate (v) ->
2ffa112 @visnup got teams to actually save
visnup authored
16 1 <= v.length
17 , 'Team must have at least one member'
18
969876a @visnup start directing to team creation
visnup authored
19 TeamSchema.path('emails').validate (v) ->
2ffa112 @visnup got teams to actually save
visnup authored
20 v.length <= 4
21 , 'At most four members are allowed on a team'
22
969876a @visnup start directing to team creation
visnup authored
23 Team = module.exports = mongoose.model 'Team', TeamSchema
24
25 Team.prototype.includes = (person) ->
26 _.any this.people_ids, (id) -> id.equals(person.id)
Something went wrong with that request. Please try again.