Skip to main content
Module

x/ldkit/mod.ts>Lens#findOne

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

Find one entity that matches the given search criteria.

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

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);

// Find one person with name that starts with "Ada"
const person = await Persons.findOne({
  name: { $strStarts: "Ada" },
});

Parameters

optional
where: SchemaSearchInterface<T>

Search criteria and pagination options