Created
March 31, 2015 19:33
-
-
Save antoniogarrote/065acdc5f46e328961ba to your computer and use it in GitHub Desktop.
RDFInterfaces usage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RDFInterfaces = require('./src/rdf_model'); | |
var RdfstoreStore = function (options) { | |
if (options == null) { | |
options = {}; | |
} | |
var self = this; | |
this.graph = function (iri, callback) { | |
self.graph = new RDFInterfaces.Graph(); | |
if(callback != null) | |
callback(graph); | |
return self; | |
}; | |
this.match = function (iri, subject, predicate, object, callback, limit) { | |
callback(self.graph.match(subject, predicate, object, limit)); | |
return self; | |
}; | |
this.add = function (iri, graph, callback) { | |
self.graph.addAll(graph); | |
if(callback != null) | |
callback(self.graph); | |
return self; | |
}; | |
}; | |
new RdfstoreStore() | |
.graph("http://test.com") | |
.add(null,new RDFInterfaces.Graph(). | |
add(new RDFInterfaces.Triple(new RDFInterfaces.NamedNode("http://test.com#subject"), | |
new RDFInterfaces.NamedNode("http://test.com#predicate"), | |
new RDFInterfaces.NamedNode("http://test.com#object")))) | |
.match(null,new RDFInterfaces.NamedNode("http://test.com#subject"),null,null, function(resultGraph){ | |
console.log("RESULT:"); | |
console.log(resultGraph.toNT()); | |
}, 10); | |
/* renders | |
RESULT: | |
<http://test.com#subject> <http://test.com#predicate> <http://test.com#object> . | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment