summaryrefslogtreecommitdiff
path: root/server/api/party.js
blob: 53a0d323acd8a409f8087ae9cfc543e4f95c90e3 (plain)
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
var _ = require('lodash'),
    User = require('../models/User'),
    Party = require('../models/Party'),
    UserParty = require('../models/UserParty');

module.exports = {
	list: function (req, res) {
		Party.all().success(function(parties){
			res.json(parties)
		})
	},
	
	view: function (req, res) {
		var party_id = res.body.party_id
		UserParty.findAll({ where: { party_id: party_id } }).success(function(parties){
			var user_ids = _.pluck(parties, user_id)
			User.findAll({ where: { id: user_ids } }).success(function(users){
				res.json(users)
			})
		})
	},
	
	edit: function (req, res) {
	}
}