database/index.js
// Inserts a new Poll into the db
Inserts a new Poll into the db
Inserts a new Poll into the db
function voteOnPoll(pollID, votes) {
	let query = 'UPDATE poll SET votes = (SELECT array_agg(vote) FROM ( SELECT title, (unnest(votes)::integer + unnest($2::integer[])::integer) AS vote FROM poll WHERE poll_id = $1) as unnested_vote) WHERE poll_id = $1'
	return new Promise((resolve, reject) => {
		pool.query(query, [pollID, votes])
		.then(result => {
			resolve(result.rows[0]);
		})
		.catch(e => reject(e));
	});
}
function voteOnPoll ( pollID , votes ) { let query = 'UPDATE poll SET votes = (SELECT array_agg(vote) FROM ( SELECT title, (unnest(votes)::integer + unnest($2::integer[])::integer) AS vote FROM poll WHERE poll_id = $1) as unnested_vote) WHERE poll_id = $1' return new Promise ( ( resolve , reject ) => { pool . query ( query , [ pollID , votes ] ) . then ( result => { resolve ( result . rows [ 0 ] ) ; } ) . catch ( e => reject ( e ) ) ; } ) ; }
Inserts a new Poll into the db
Inserts a new Poll into the db