Javascript SDK

RecordLink

Reference a record.

const recordLink = {
  entity: "alice.baq.run",
  recordId: "012a494c14154f2c91e35f34e077e5be",
};
  • new(entity: Entity, recordId: RecordId): RecordLink

    • Create a new record link from an entity and record ID.
  • toKey(recordLink: RecordLink): RecordKey

    • Get the corresponding key from a record link.
  • isRecord(record: Record, recordLink: RecordLink): boolean

    • Check whether a record link matches the provided record.
  • entity Entity

    • Current entity representing the target record’s initial author.
  • originalEntity Entity optional

    • Entity that represented the target record’s initial author at the time the referencing record version was created, if different.
  • recordId RecordId

    • Unique identifier of the record within the scope of its initial author.

Once created, a record link can be used in the content of a record that accepts a link of the same type. In this example, we create a Folder record­ with another folder as parent.

import {Record} from "@baqhub/sdk";
import {FolderRecord} from "./baq/folderRecord.js";

function createSubFolder(entity, name, parent) {
  const parentLink = Record.toLink(parent);

  return FolderRecord.new(entity, {
    name,
    parent: parentLink,
  });
}
© 2024 Quentez