const { setSurvey, transaction } = require('../connection');

async function put (projectId, eventId, payload, opts = {}) {

	const p = payload; // Shorter
	const client = await setSurvey(projectId);
	try {

		const text = `
			UPDATE event_log
			SET
				tstamp = $1,
				sequence = $2,
				point = $3,
				remarks = replace_placeholders($4, $1, $2, $3),
				labels = $5
			WHERE id = $6;
		`;
		const values = [ p.tstamp, p.sequence, p.point, p.remarks, p.labels, eventId ];

		await client.query(text, values);
	} catch (err) {
		throw err;
	} finally {
		client.release();
	}

	return;
}

module.exports = put;
