Page 1 of 1

Easy way to check if a database entry exists

Posted: Mon Aug 01, 2016 3:10 am
by EulersIdentity
I want to check if a row exists with a particular field value and get a boolean value of whether or not it's there. Here's what I'm doing right now:
Code: [show] | [select all] lua
function db_exists(sheet, field, val)
	local t = db:fetch(sheet, db:eq(field, val))
	if t[1] then return true else return false end
Is there a quick way to do that which already exists? This seems inelegant.