Easy way to check if a database entry exists

Post Reply
EulersIdentity
Posts: 27
Joined: Fri Jun 26, 2015 8:52 am

Easy way to check if a database entry exists

Post 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
end
Is there a quick way to do that which already exists? This seems inelegant.

Post Reply