Updating RDF/JS stores


On this page

    One of the different types of destinations that is supported by Comunica is the RDF/JS Store interface. This allows you to pass objects as destination to Comunica as long as they implement this interface.

    Learn more about RDF/JS in this RDF/JS guide.

    Several implementations of this Store interface exist. In the example below, we make use of the Store from N3.js that offers one possible implementation when you want to query over it with Comunica within a JavaScript application:

    const store = new N3.Store();
    
    const query = `
    PREFIX dc: <http://purl.org/dc/elements/1.1/>
    INSERT DATA
    { 
      <http://example/book1> dc:title "A new book" ;
                             dc:creator "A.N.Other" .
    }
    `;
    
    // Execute the update
    await myEngine.queryVoid(query, {
      sources: [store],
    });
    
    // Prints '2' => the store is updated
    console.log(store.size);