The Xooa Ledger Database (XLDB) is comprised of two databases: A mutable document datastore called the State Database, or World State, and an immutable database called the Transaction Database, or simply the Ledger. The Ledger is append-only and cryptographically protected against modifications using blockchain technology.
When a key-value pair is created or updated, the World State is modified using a transaction. The transaction is appended to the ledger. All changes to key-value pairs (including deletions) are recorded in the ledger and can be queried via the History endpoint.
The key uniquely identifies the key-value pair within the World State database. The most appropriate method for constructing keys varies by use case. For example, if you are only interested in the append-only nature of the XLDB, and not in the state db, or rich query, it doesn’t matter what you use as a key, and you may find it convenient to use the same key for all transactions. You can use the History endpoint to fetch all transactions and their associated payloads.
If you wish to search based on the content of each transaction (the payload), you will then need a unique key (such as uuid) for each transaction because such a search can run only against the State Database (see Query endpoint for more details)
The XLDB State Database may be used to store different object types (such as cars and people), typically using different JSON document schemas. If this is your use case, it makes sense to combine the object type and the unique object identifier into a single key. Another best practice with multiple object types is to denote the object type within the JSON representation of the value. It will facilitate query filtering by object types.
It is recommended that values are formatted as JSON objects to effectively utilize the rich query capabilities of the query endpoint.
The XLDB enriches values with metadata fields such as the identity of the token holder that created or modified the key, along with the created and the last-modified date. These metadata fields may be used to filter a query using the Query endpoint.
More details on the XLDB APIs can be read and tried here.
More details about World State, Transactions, and other app-related features can be read here.
Do you prefer video tutorials? Check out the video tutorial for XLDB here.