For AI agents: the complete documentation index is available at /lite-db/en/llms.txt, the full documentation bundle is available at /lite-db/en/llms-full.txt, and this page is available as Markdown at /lite-db/en/api.md.

API

The runtime entry point is Achieve.Database.LiteDB.

Initialize

LiteDB.Initialize(path);

Connects immediately using the given SQLite file path.

await LiteDB.Initialize();

Copies the default DB file from StreamingAssets/data/file.db to persistentDataPath/data/localdatasqlite.db, then connects.

Get

var item = LiteDB.Get<ItemData>(1);

Returns the first row whose primary key or Id column equals the given value. Returns default when not initialized.

GetList

var items = LiteDB.GetList<ItemData>(100, 199);

Queries rows in the range Id >= startId AND Id <= endId.

Exist

if (LiteDB.Exist<ItemData>(10))
{
    // exists
}

Checks whether an Id exists in the table for the given type.

TryGetValue

if (LiteDB.TryGetValue<ItemData>(10, out var item))
{
    Debug.Log(item.Name);
}

Checks existence and returns the data via out if present. Returns false when not initialized or when no data exists.

Using SQLiteConnection directly

For advanced use, you can use SQLite.SQLiteConnection directly.

using var db = new SQLiteConnection(path);
var rows = db.Query<ItemData>("SELECT * FROM ItemData WHERE Price >= ?", 100);
var count = db.ExecuteScalar<int>("SELECT COUNT(1) FROM ItemData");

The direct API provided is query-focused. It does not include the full sqlite-net ORM features, LINQ table queries, or an async connection pool.