Browse a luna's data
Find lunas, read and change their rows, manage their files, and look at indexes and sandboxes from the luna CLI.
Each luna keeps its own tables and files, so a database client cannot reach them. When a bug report names one customer, you need to see that customer’s luna as it is.
The luna data, luna files, luna indexes and luna sandboxes commands read a luna’s contents from your terminal. They act on the environment the folder uses, and --env picks another.
Find a luna
luna data lunas lists the keys of a luna type’s lunas, 100 at a time unless you pass --limit.
luna data lunas List
Pass --search to keep the keys that hold some text in any field, ignoring case. For a key of several fields, a / b looks for a in the first field and b in the second.
luna data lunas Card --search "b1 / c"
Name a luna in the other commands
The other commands take the luna type, then the key. For a key of one field, write that field’s value alone.
luna data rows List groceries items
For a key of several fields, write the key as JSON.
luna data rows Card '{"board":"b1","card":"c1"}' notes
Read a table’s rows
luna data rows prints a page of a table’s rows, 50 unless you pass --limit. Each row starts with its rowid, which the commands that change a row take.
When more rows follow, the command prints the --after value that reads the next page.
luna data rows List groceries items --after <ROWID>
Pass --json to get the rows as JSON instead of a table. Columns that Luna keeps for itself are not shown.
Change, add and delete rows
luna data set changes one value of one row. Numbers, true, false and JSON are read as the column’s type takes them, and --null empties the value.
luna data set List groceries items <ROWID> done true
luna data add adds a row from column=value pairs, and the columns you leave out take their defaults. It prints the new row’s rowid.
luna data add List groceries items text=milk done=false
luna data delete removes one row. It asks first, and --yes answers in advance.
luna data delete List groceries items <ROWID>
These changes land like a write from a handler, so live queries see them. No handler of the luna runs for them. A change the table refuses, such as one that breaks a constraint, changes nothing.
Columns of bytes or vectors cannot be set from the CLI. Set those from your code. An index’s rows change only through the tables it reads from.
Work with a luna’s files
luna files reaches the files in the buckets a luna type’s code defines. luna files list shows a folder, its subfolders first.
luna files list List groceries attachments items/
| Command | Does |
|---|---|
luna files get <TYPE> <KEY> <BUCKET> <PATH> |
Downloads a file. -o - writes it to standard output |
luna files put <TYPE> <KEY> <BUCKET> <PATH> <FILE> |
Uploads a file, replacing what is at that path |
luna files delete <TYPE> <KEY> <BUCKET> <PATH> |
Deletes a file after asking. It cannot be undone |
luna files url <TYPE> <KEY> <BUCKET> <PATH> |
Prints a signed URL that anyone can download from |
A signed URL lasts one hour unless you pass --expires, and at most 7 days. Store files explains buckets.
Look at indexes
luna indexes lists the environment’s indexes, and the name of one shows it in full. Indexes are read only here, since your code and luna deploy make and change them.
luna indexes find <INDEX> --partition <VALUE> --search "<WORDS>"
luna indexes find reads the rows of one partition, up to 50 unless you pass --limit. Query across lunas explains indexes.
Look at sandboxes
luna sandboxes list lists the sandboxes of the environment’s lunas, or of one type when you name it.
luna sandboxes stop powers a running sandbox off and keeps its disks, and the next request to it boots it again. luna sandboxes delete removes a sandbox with its disks after asking, and it cannot be undone.
luna sandboxes stop <TYPE> <KEY> <NAME>
Browse in the Console
The Console shows the same data. On an environment’s page, select a luna type, then a table under Data or a bucket under Files.
Next steps
- Fork a luna gives you a copy to edit instead of the original.
- Restore to an earlier moment rewinds a luna after a wrong edit.
- Query across lunas shows how indexes collect rows from many lunas.