database/index.js
// Checks if the user has already voted
Checks if the user has already voted
Checks if the user has already voted
function userHasVoted(pollID, userID) {
	let query = 'SELECT user_id FROM poll_vote WHERE (poll_id = $1) AND (user_id = $2)';
	return new Promise((resolve, reject) => {
		pool.query(query, [pollID, userID])
		.then(result => {
			resolve(result.rows.length > 0);
		})
		.catch(e => reject(e));
	});
}
function userHasVoted ( pollID , userID ) { let query = 'SELECT user_id FROM poll_vote WHERE (poll_id = $1) AND (user_id = $2)' ; return new Promise ( ( resolve , reject ) => { pool . query ( query , [ pollID , userID ] ) . then ( result => { resolve ( result . rows . length > 0 ) ; } ) . catch ( e => reject ( e ) ) ; } ) ; }
Checks if the user has already voted
Checks if the user has already voted