import { Lens } from "https://deno.land/x/ldkit/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
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" },
});