Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface Operation

TODO: Researching.

Examples

Add a new block

Create a block.

{
  id: "<generate_one>",
  table: "block",
  path: [],
  command: "update",
  args: {
    id: "<the_same_as_above_one>",
    type: "<block_type>",
    properties: {},
    parent_id: "<parent_id>",
    parent_table: "block",
    alive: true,
    created_by: "<user_id>",
    created_time: <timestamp>,
    last_edited_by: "user_id",
    last_edited_time: <timestamp>
  }
}

Place it somewhere.

{
  id: "<parent_id>",
  table: "block",
  path: ["content"],
  command: "listAfter",
  args: {
    after: "<sibling_id>",
    id: "<new_block_id>"
  }
}

Soft-Delete a block

First set the block to { alive: false }.

{
  id: "<block_id>",
  table: "block",
  path: [],
  command: "update",
  args: { alive: false }
}

Then, remove it from its parent.

{
  id: "<parent_block_id>",
  table: "block",
  path: ["content"],
  command: "listRemove",
  args: {
    id: "<block_id>"
  }
}

Finally, Update its and its parent's last_edited_time.

Move a block

Soft-Delete a block → Update its parent and set { alive: true } → Place it after another block → Update its and its parent's last_edited_time.

Hierarchy

  • Operation

Index

Properties

Properties

args

args: any

The arguments of this operation. Type varies with operation.

Examples :

Set page title — SemanticString[]
Set page icon — string : an URL or an emoji
Set last edited time — number
Remove value of a property by setting args to null.

command

command: "set" | "update" | "listAfter" | "listRemove"

TODO: Incomplete

Guess: Use "set" with a path to set a property, and use "update" without path to set more than one properties, so are they interchangeable in general ?

id

id: UUID

Use id + table to specify which record to operate on.

path

path: string[]

An object key path relative to the record. For example, to change the title of a Page, since the title is stored in "Page.properties.title", we need to specify ["properties", "title"] here.

table

table: Table

Generated using TypeDoc