pub struct LogEntry {
pub cmd: String,
pub collection: String,
pub key: String,
pub value: Value,
pub _t: u64,
}Expand description
The atomic unit of data in MoltenDB’s append-only log.
Every mutation to the database is recorded as a LogEntry appended to the log file. On startup, the log is replayed from top to bottom to rebuild the in-memory state. This is the “log-structured” part of MoltenDB.
The four command types and their meanings:
“INSERT” — insert or overwrite a document.
collection = which collection, key = document ID,
value = the full JSON document.
“DELETE” — delete a single document.
collection + key identify the document; value is null.
“DROP” — delete an entire collection.
collection = which collection; key and value are unused.
“INDEX” — record that an index was created on a field.
collection = which collection, key = field name,
value is null. The index data itself is rebuilt from the
INSERT entries during replay.
“TX_BEGIN” — marks the start of an atomic batch transaction.
key = transaction ID (e.g. UUID).
“SCHEMA” — register a JSON schema for a collection.
collection = which collection, value = the schema JSON.
“ENC” — a sentinel used by EncryptedStorage. The real LogEntry is
encrypted inside value as a base64 string. The engine
never sees ENC entries directly — EncryptedStorage decrypts
them before returning them from read_log().
Fields§
§cmd: StringThe command type: “INSERT”, “DELETE”, “DROP”, “INDEX”, “TX_BEGIN”, “TX_COMMIT” or “ENC”.
collection: StringThe name of the collection this entry belongs to.
key: StringThe document key (for INSERT/DELETE) or field name (for INDEX).
value: ValueThe document value (for INSERT) or null (for DELETE/DROP/INDEX). For ENC entries, this holds the base64-encoded ciphertext.
_t: u64Engine-level timestamp (Unix milliseconds) for Point-in-Time Recovery.