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 » Mon Aug 01, 2016 3:10 am

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

Who is online

Users browsing this forum: Baidu [Spider], Bing [Bot] and 6 guests