head, tail and wc -l to your backend’s queries and live
updates. A database can fetch a few rows or count them without exporting the
whole table. A chat service can send new messages to tail -f.
Example: inspect a table
With PostgreSQL mounted at/db/:
LIMIT to fetch the first 20 rows and COUNT(*) to count them.
Adding a byte count with wc -lc requires reading the file instead.
Connect your own backend
Override the methods your service supports:
The TypeScript names are
firstLines, lastLines, lineCount and follow.
For first_lines and last_lines, N must be positive. Standard input is
always read normally.
For follow, first yield the last N lines, then new lines as they arrive.
Keep the stream open until the caller closes it; ending it makes tail -f
exit with an error.
Return the same content and order as a normal file read. Return None in
Python or null in TypeScript when a method cannot answer; Mirage reads the
file normally.