Skip to content

Instantly share code, notes, and snippets.

@antoniogarrote
Created March 31, 2015 19:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save antoniogarrote/065acdc5f46e328961ba to your computer and use it in GitHub Desktop.
Save antoniogarrote/065acdc5f46e328961ba to your computer and use it in GitHub Desktop.
RDFInterfaces usage
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