Details about the Database Structure

I’d rather invest time in providing a good API for accessing the data, than encouraging people to read and write to the database directly. That way, any changes to the underlying database format don’t lead to breakages, as we can freely change the underlying format while preserving the API, and it avoids issues like this one that popped up today: Newly added notes are immediately deleted (broken deck / collection?).

The interval is negative and in seconds for (re)learning cards in the v2 scheduler only. In the v3 scheduler, it is in days and positive.

The Rust code contains a fair bit of documentation. If you look up RevlogEntry:

/// Positive values are in days, negative values in seconds.
#[serde(rename = "ivl", deserialize_with = "deserialize_int_from_number")]
pub interval: i32,

v3 will use seconds or days depending on if it’s an intraday/interday learning card; v2 always used seconds. If you interpret the value based on the sign, the code should work for both v2 and v3.

3 Likes