LDkit
    Preparing search index...

    Function encodeEntity

    • Encodes an entity to RDF quads according to a data schema, without a data source. The quads are the ones Lens.prototype.insert writes. Options set with setGlobalOptions apply.

      Type Parameters

      Parameters

      Returns Quad[]

      RDF quads of the entity

      import { encodeEntity } from "ldkit";
      import { schema, xsd } from "ldkit/namespaces";

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

      // Encode a person to RDF quads
      const quads = encodeEntity(PersonSchema, {
      $id: "http://example.org/Alan_Turing",
      name: "Alan Turing",
      birthDate: new Date("1912-06-23"),
      });