antoniogarrote/rdfstore-js — Issue #18: Mongo persistence setup?
Author: oneHappyCanuck
Created: 2012-01-26 06:56:32+00:00
State: open

I'm trying out the MongoDb RDF persistence but can't seem to get any statements actually written into Mongo; my test script below. Is it necessary to run the SPARQL endpoint for persistence? The launch script for that isn't included with the npm install distribution, and after building the node.js version (from zip) the script throws error cannot find module './index'.

Any help appreciated :)

var rdfstore = require('rdfstore');

new rdfstore.Store({persistent:true,
engine:'mongodb',
name:'mwa', // quads in MongoDB will be stored in a DB named mwa
overwrite:false, // delete all the data already present in the MongoDB server
mongoDomain:'localhost', // location of the MongoDB instance, localhost by default
mongoPort:27017 // port where the MongoDB server is running, 27017 by default
}, function( store ){

store.execute('SELECT * { ?s ?p ?o }', function(success,results) {
console.log('\n\nFIRST SELECT returned ' + success + ' and results ' + JSON.stringify(results) );
if ( results.length==0) {
// try an insert and then a query
store.execute('INSERT DATA { }', function(result, msg){
console.log('\n\nINSERT returned ' + result + ' and msg ' + JSON.stringify(msg) );
store.execute('SELECT * { ?s ?p ?o }', function(success,results) {
console.log('select returned ' + success + ' and results ' + JSON.stringify(results) );
});
});
}
});

});