-
Notifications
You must be signed in to change notification settings - Fork 0
/
sparql-queries.js
31 lines (26 loc) · 1.06 KB
/
sparql-queries.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
var path = require('path');
var { SPARQL } = require(path.join(__dirname, 'sparql'));
var selectThermostatByLocation = function(location) {
return SPARQL`
PREFIX demo: <http://mu.semte.ch/vocabularies/ext/apiai-demo/>
SELECT ?thermostat ?temperature WHERE {
GRAPH ${{ value: process.env.MU_APPLICATION_GRAPH, type: 'uri' }} {
?thermostat a demo:Thermostat ;
demo:location ${location} ;
demo:temperature ?temperature .
}
} LIMIT 1`;
}
var insertTemperature = function(thermostat, temperature) {
return SPARQL`
PREFIX demo: <http://mu.semte.ch/vocabularies/ext/apiai-demo/>
WITH ${{ value: process.env.MU_APPLICATION_GRAPH, type: 'uri' }}
DELETE { ${{ value: thermostat, type: 'uri' }} demo:temperature ?temperature }
INSERT { ${{ value: thermostat, type: 'uri' }} demo:temperature ${{ value: temperature, type: 'decimal' }} }
WHERE { ${{ value: thermostat, type: 'uri' }} demo:temperature ?temperature }
`
}
module.exports = {
selectThermostatByLocation: selectThermostatByLocation,
insertTemperature: insertTemperature
};