Getting Started
This page walks through the minimal flow from installation to your first query.
Installation
In Unity Package Manager, open Add package from git URL... and enter the address below.
Dependencies
Targets Unity 2022.3 or later.
Preparing the DB file
LiteDB reads a SQLite DB file and maps it to C# models. You can create the DB file with a tool such as DB Browser for SQLite.
The default initialization API uses the following locations.
Place the source DB file at StreamingAssets/data/file.db.
Writing a data model
Write a C# class that corresponds to the table you want to query. Using Id as the primary key is recommended.
Initialization and first query
Call await LiteDB.Initialize() at game start to copy the source DB file to the runtime path and connect. After that, read data with APIs like LiteDB.Get<T>(id).
On Android, StreamingAssets files are read via UnityWebRequest; on other platforms, file copy is used. To specify a path directly, use LiteDB.Initialize(path).
Next steps
- Usage › Data Models — model rules and attributes
- API — the full runtime API