Skip to content
Luna
Esc
↑↓navigate↵open⌘Jpreview
On this page

luna data

List a type's lunas, read a page of a luna's table, change, add or delete one row, and let a quarantined luna run again.

luna data reads the tables of one luna, and changes them one value or one row at a time.

luna data rows List groceries items

Reference

luna data <COMMAND>

Every subcommand acts on one environment, and takes these options.

Option Type Default Does
--dir <DIR> path . The app’s folder. Its env file names the project and environment.
--env <ENV> text LUNA_ENV, then production The environment, by name.
--project <PROJECT> text LUNA_PROJECT The project, by name or as organisation/project.
--tenant <TENANT> text The environment’s own A tenant added to the environment, by name.
--token <TOKEN> text LUNA_TOKEN, then your login An API token or account key to act with.

luna data lunas

Lists the lunas of a type by key, one a line.

luna data lunas [OPTIONS] <TYPE>
Option Type Default Does
<TYPE> text Required The luna type, by name.
--limit <LIMIT> number 100 How many keys to list.
--search <TEXT> text None Lists only lunas whose key holds this text in any field, ignoring case. a / b looks for a in the first key field and b in the second.
--json flag Off Prints the answer as JSON.

luna data rows

Prints a page of one table, in rowid order, with the rowid the other subcommands take.

luna data rows [OPTIONS] <TYPE> <KEY> <TABLE>
Option Type Default Does
<TYPE> text Required The luna type, by name.
<KEY> text Required The luna’s key.
<TABLE> text Required The table, by name.
--limit <LIMIT> number 50 How many rows to print, at most 1000.
--after <ROWID> number None Starts after this rowid. When there are more rows, the command prints the rowid to pass.
--json flag Off Prints the answer as JSON.

luna data set

Changes one value of one row.

luna data set [OPTIONS] <TYPE> <KEY> <TABLE> <ROWID> <COLUMN> [VALUE]
Option Type Default Does
<ROWID> number Required The row, by its rowid.
<COLUMN> text Required The column to change.
[VALUE] text Required unless --null The new value, read as the column’s type takes it.
--null flag Off Empties the value instead. The column must allow null.

luna data add

Adds a row and prints its rowid. Each column you leave out takes its default.

luna data add [OPTIONS] <TYPE> <KEY> <TABLE> [COLUMN=VALUE]...
Option Type Default Does
[COLUMN=VALUE] text, repeatable None A column to set and its value, read as the column’s type takes it.

luna data delete

Deletes one row. It asks first.

luna data delete [OPTIONS] <TYPE> <KEY> <TABLE> <ROWID>
Option Type Default Does
<ROWID> number Required The row, by its rowid.
--yes flag Off Deletes without asking.

luna data release

Lets a quarantined luna run again, and wakes it.

luna data release [OPTIONS] <TYPE> <KEY>
Option Type Default Does
<TYPE> text Required The luna type.
<KEY> text Required The luna’s key.

Good to know

  • A key with one field is given as its value, such as groceries. A key with several fields is given as JSON, such as '{"board":"b1","card":"c7"}'.
  • A value is read as its column’s type takes it. An integer column and a time take a whole number, a time in milliseconds. A boolean takes true, false, 1 or 0. A JSON column takes JSON, and keeps other text as a string.
  • Bytes and vectors show only their size, and only your code can set them. Luna’s own columns stay hidden.
  • A luna makes a table with its first write to it. Until then rows prints no rows, and set, add and delete are refused.
  • A change runs as a handler’s write does. It is stored whole or not at all, and apps subscribed to a live query see it.
  • An index shows its rows table alone, and refuses every change. Read indexes with luna indexes.
  • Reading needs the data:read scope. Changing, and release, need data:write.
  • release leaves a luna that is not quarantined as it is. Fix what made it crash first, or it crashes again and goes back into quarantine.
  • Without a terminal to ask at, delete stops with exit code 6 unless you pass --yes.

Examples

List every luna of a type

luna data lunas List --limit 500

Find lunas by their key

luna data lunas Card --search "b1 / c7"

Read the next page of a table

luna data rows List groceries items --after 50

Change one value

luna data set List groceries items 3 text "Oat milk"

Add a row

luna data add List groceries items text=Bread

Delete a row in a script

luna data delete List groceries items 3 --yes

Was this page helpful?