Skip to main content
Module

x/ldkit/mod.ts>Lens

LDkit - Linked Data query toolkit for TypeScript developers
Latest
class Lens
import { Lens } from "https://deno.land/x/ldkit@2.0.0/mod.ts";

Lens provides an interface to Linked Data based on the data schema.

For the best developer experience, use the createLens function to create the instance.

Constructors

new
Lens(schema: T, options?: Options)

Properties

private
readonly
engine: QueryEngineProxy
private
readonly
options: Options
private
readonly
queryBuilder: QueryBuilder
private
readonly
schema: ExpandedSchema

Methods

private
decode(graph: Graph)
private
log(query: string)
private
updateQuery(query: string)
count(): Promise<number>

Returns the total number of entities corresponding to the data schema.

delete(...identities: Identity[] | IRI[]): Promise<void>

Deletes one or more entities from the data store.

This method accepts IRIs of the entities to delete and attemps to delete all triples from the database that corresponds to the data schema. Other triples that are not covered by the data schema will not be deleted.

If you need to have more control of what triples to delete, use deleteData instead.

deleteData(...quads: RDF.Quad[]): Promise<void>

Deletes raw RDF quads from the data store.

This method is useful when you need to delete data that is not covered by the data schema.

find(options?: { where?: SchemaSearchInterface<T> | string | RDF.Quad[]; take?: number; skip?: number; }): Promise<Unite<SchemaInterface<T>>[]>

Find entities that match the given search criteria.

The search criteria is a JSON object that may contain properties from the data schema. In addition you can specify how many results to return and how many to skip for pagination purposes.

findByIri(iri: IRI): Promise<Unite<SchemaInterface<T>> | null>

Find a single entity that matches the given IRI.

findByIris(iris: IRI[]): Promise<Unite<SchemaInterface<T>>[]>

Find entities that match the given IRIs.

Find one entity that matches the given search criteria.

The search criteria is a JSON object that may contain properties from the data schema.

insert(...entities: Entity<SchemaInterface<T>>[]): Promise<void>

Inserts one or more entities to the data store.

insertData(...quads: RDF.Quad[]): Promise<void>

Inserts raw RDF quads to the data store.

This method is useful when you need to insert data that is not covered by the data schema.

query(sparqlConstructQuery: string): Promise<Unite<SchemaInterface<T>>[]>

Find entities with a custom SPARQL query.

The query must be a CONSTRUCT query, and the root nodes must be of type ldkit:Resource. So that the decoder can decode the results, the query must also return all properties according to the data schema.

update(...entities: SchemaUpdateInterface<T>[]): Promise<void>

Updates one or more entities in the data store.