Skip to Content
Quickstart

Quickstart

Two ways to run DocumentForge: embedded in your .NET process, or as a server behind an HTTP API. Pick whichever matches how you want to deploy — the storage engine and query language are identical.

Add the package

dotnet add package DocumentForge

Open a database and insert a document

using DocumentForge.Engine; using var db = DocumentForgeDb.OpenOrCreate("app.dfdb"); db.Insert("orders", """ { "pnr": "ABC123", "passenger": { "firstName": "John", "lastName": "Smith" }, "flights": [{ "flightNumber": "AA100", "from": "JFK", "to": "LAX" }] } """);

Add an index and query

db.CreateIndex("orders", "pnr", "idx_pnr", unique: true); var result = db.Execute("SELECT * FROM orders WHERE pnr = 'ABC123'"); foreach (var doc in result.Documents) Console.WriteLine(doc);

The index makes WHERE pnr = … a direct lookup rather than a scan, and it persists across restarts — no rebuild on startup.

Prefer LINQ? db.Collection<Order>("orders").Where(o => o.Pnr == "ABC123").FirstOrDefault() works against the same data. See the .NET SDK reference.

Next steps

Last updated on