Skip to content

Commit

Permalink
Update firstValue.lua
Browse files Browse the repository at this point in the history
  • Loading branch information
JeroenDeDauw authored Nov 25, 2023
1 parent 6cc456d commit 1f2a961
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions demoLua/firstValue.lua
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
local sparql = require('SPARQL')
local sparql = require('SPARQL') -- Load the SPARQL binding

local p = {}

function p.showFirstValue(frame)
local sparqlQuery = frame.args[1]
local queryResults = sparql.runQuery(sparqlQuery)
local queryResults = sparql.runQuery(sparqlQuery) -- Use the runQuery method

-- nil is returned if Blazegraph did not return a valid response
if queryResults == nil then
return ''
end

-- Replace "work" with the first SELECT variable in your SPARQL query
return queryResults['results']['bindings'][1]['work']['value']
Expand Down

0 comments on commit 1f2a961

Please sign in to comment.