Skip to main content
Module

x/ldkit/mod.ts>Lens#findByIri

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

Find a single entity that matches the given IRI.

Examples

Example 1

import { createLens } from "ldkit";
import { schema } from "ldkit/namespaces";

// Create a schema
const PersonSchema = {
  "@type": schema.Person,
  name: schema.name,
} as const;

// Create a resource using the data schema above
const Persons = createLens(PersonSchema);

// Get a particular person identified by IRI
const ada = await Persons.findByIri("http://dbpedia.org/resource/Ada_Lovelace");
console.log(ada?.name); // string "Ada Lovelace"

Parameters

iri: IRI

IRI of the entity to find

Returns

Promise<Unite<SchemaInterface<T>> | null>

Entity if found, null otherwise