Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/ldkit/library/sparql/sparql_update_builders.ts>WITH

LDkit - Linked Data query toolkit for TypeScript developers
Latest
variable WITH
import { WITH } from "https://deno.land/x/ldkit@2.0.0/library/sparql/sparql_update_builders.ts";

SPARQL WITH query fluent interface

Examples

Example 1

import { DELETE } from "ldkit/sparql";
import { foaf } from "ldkit/namespaces";
import { DataFactory } from "ldkit/rdf";

const df = new DataFactory();
const firstName = df.namedNode(foaf.firstName);
const graph = df.namedNode("http://example.org/graph");

const query = WITH(graph).DELETE`?person ${firstName} "Jean"`
  .INSERT`?person ${firstName} "Paul"`
  .WHERE`?person ${firstName} "Jean"`
  .build();
console.log(query);
// WITH <http://example.org/graph>
// DELETE { ?person <http://xmlns.com/foaf/0.1/firstName> "Jean" }
// INSERT { ?person <http://xmlns.com/foaf/0.1/firstName> "Paul" }
// WHERE { ?person <http://xmlns.com/foaf/0.1/firstName> "Jean" }

type

(stringOrNamedNode: string | RDF.NamedNode<string>) => unknown