LiteDB 5.0.15

.NET Standard 1.3 .NET Framework 4.5
dotnet add package LiteDB --version 5.0.15
NuGet\Install-Package LiteDB -Version 5.0.15
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="LiteDB" Version="5.0.15" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add LiteDB --version 5.0.15
#r "nuget: LiteDB, 5.0.15"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install LiteDB as a Cake Addin
#addin nuget:?package=LiteDB&version=5.0.15

// Install LiteDB as a Cake Tool
#tool nuget:?package=LiteDB&version=5.0.15

LiteDB - A .NET NoSQL Document Store in a single data file

Join the chat at https://gitter.im/mbdavid/LiteDB Build status Build Status


LiteDB is a small, fast and lightweight .NET NoSQL embedded database.

  • Serverless NoSQL Document Store
  • Simple API, similar to MongoDB
  • 100% C# code for .NET 4.5 / NETStandard 1.3/2.0 in a single DLL (less than 450kb)
  • Thread-safe
  • ACID with full transaction support
  • Data recovery after write failure (WAL log file)
  • Datafile encryption using DES (AES) cryptography
  • Map your POCO classes to BsonDocument using attributes or fluent mapper API
  • Store files and stream data (like GridFS in MongoDB)
  • Single data file storage (like SQLite)
  • Index document fields for fast search
  • LINQ support for queries
  • SQL-Like commands to access/transform data
  • LiteDB Studio - Nice UI for data access
  • Open source and free for everyone - including commercial use
  • Install from NuGet: Install-Package LiteDB

New v5

  • New storage engine
  • No locks for read operations (multiple readers)
  • Write locks per collection (multiple writers)
  • Internal/System collections
  • New SQL-Like Syntax
  • New query engine (support projection, sort, filter, query)
  • Partial document load (root level)
  • and much, much more!

Lite.Studio

New UI to manage and visualize your database:

LiteDB.Studio

Documentation

Visit the Wiki for full documentation. For simplified chinese version, check here.

LiteDB Community

Help LiteDB grow its user community by answering this simple survey

How to use LiteDB

A quick example for storing and searching documents:

// Create your POCO class
public class Customer
{
    public int Id { get; set; }
    public string Name { get; set; }
    public int Age { get; set; }
    public string[] Phones { get; set; }
    public bool IsActive { get; set; }
}

// Open database (or create if doesn't exist)
using(var db = new LiteDatabase(@"MyData.db"))
{
    // Get customer collection
    var col = db.GetCollection<Customer>("customers");

    // Create your new customer instance
    var customer = new Customer
    { 
        Name = "John Doe", 
        Phones = new string[] { "8000-0000", "9000-0000" }, 
        Age = 39,
        IsActive = true
    };

    // Create unique index in Name field
    col.EnsureIndex(x => x.Name, true);

    // Insert new customer document (Id will be auto-incremented)
    col.Insert(customer);

    // Update a document inside a collection
    customer.Name = "Joana Doe";

    col.Update(customer);

    // Use LINQ to query documents (with no index)
    var results = col.Find(x => x.Age > 20);
}

Using fluent mapper and cross document reference for more complex data models

// DbRef to cross references
public class Order
{
    public ObjectId Id { get; set; }
    public DateTime OrderDate { get; set; }
    public Address ShippingAddress { get; set; }
    public Customer Customer { get; set; }
    public List<Product> Products { get; set; }
}        

// Re-use mapper from global instance
var mapper = BsonMapper.Global;

// "Products" and "Customer" are from other collections (not embedded document)
mapper.Entity<Order>()
    .DbRef(x => x.Customer, "customers")   // 1 to 1/0 reference
    .DbRef(x => x.Products, "products")    // 1 to Many reference
    .Field(x => x.ShippingAddress, "addr"); // Embedded sub document
            
using(var db = new LiteDatabase("MyOrderDatafile.db"))
{
    var orders = db.GetCollection<Order>("orders");
        
    // When query Order, includes references
    var query = orders
        .Include(x => x.Customer)
        .Include(x => x.Products) // 1 to many reference
        .Find(x => x.OrderDate <= DateTime.Now);

    // Each instance of Order will load Customer/Products references
    foreach(var order in query)
    {
        var name = order.Customer.Name;
        ...
    }
}

Where to use?

  • Desktop/local small applications
  • Application file format
  • Small web sites/applications
  • One database per account/user data store

Plugins

Changelog

Change details for each release are documented in the release notes.

Code Signing

LiteDB is digitally signed courtesy of SignPath

<a href="https://www.signpath.io"> <img src="https://about.signpath.io/assets/logo_signpath_500.png" width="150"> </a>

License

MIT

Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows
.NET Core netcoreapp1.0 netcoreapp1.1 netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard1.3 netstandard1.4 netstandard1.5 netstandard1.6 netstandard2.0 netstandard2.1
.NET Framework net45 net451 net452 net46 net461 net462 net463 net47 net471 net472 net48 net481
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen30 tizen40 tizen60
Universal Windows Platform uap uap10.0
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (254)

Showing the top 5 NuGet packages that depend on LiteDB:

Package Downloads
DeviceDetector.NET

The Universal Device Detection library for .NET that parses User Agents and detects devices (desktop, tablet, mobile, tv, cars, console, etc.), clients (browsers, feed readers, media players, PIMs, ...), operating systems, brands and models. This is a port of the popular PHP device-detector library to C#. For the most part you can just follow the documentation for device-detector with no issue.

FirebaseDatabase.net

Complex C# library for Firebase Realtime Database built on top of Firebase REST API. Among others it supports following: * Offline storage * Querying using available filters * Passing in authentication token * Streaming online changes * Directly Posting / Putting / Patching online data Streaming changes (both online and offline) are done using Reactive Extensions.

Libplanet

A .NET library for creating multiplayer online game in decentralized fashion. See also the docs for details: https://docs.libplanet.io/

TIKSN-Framework

This is a .NET Framework enhancement framework. Main features are Versioning, Finance, Currency, Foreign Exchange, Money, Pricing strategy, Telemetry, Composite Weighted Progress, Repository and Unity of Wok pattern implementation with Entity Framework Core, Network Connectivity Service and Triggering, Settings, Windows Registry configuration source, Azure Storage Repository, MongoDB Repository, NoDB Repository, Lingual and Regional Localization, Serialization, Rest Requester, Rest Repository, Dependency Injection, Composition Root Setup base classes.

FenixAlliance.ACL.Dependencies

Application Component for the Alliance Business Suite.

GitHub repositories (69)

Showing the top 5 popular GitHub repositories that depend on LiteDB:

Repository Stars
files-community/Files
Building the best file manager experience for Windows
dodyg/practical-aspnetcore
Practical samples of ASP.NET Core 2.1, 2.2, 3.1, 5.0, 6.0 and 7.0 projects you can use. Readme contains explanations on all projects.
JosefNemec/Playnite
Video game library manager with support for wide range of 3rd party libraries and game emulation support, providing one unified interface for your games.
bitwarden/mobile
The mobile app vault (iOS and Android).
JavScraper/Emby.Plugins.JavScraper
Emby/Jellyfin 的一个日本电影刮削器插件,可以从某些网站抓取影片信息。
Version Downloads Last updated
5.0.15 19,049 12/23/2022
5.0.14 5,721 12/16/2022
5.0.13 9,153 12/8/2022
5.0.12 400,594 6/15/2022
5.0.11 2,543,136 7/23/2021
5.0.10 1,374,435 1/9/2021
5.0.9 603,412 8/6/2020
5.0.8 315,380 5/13/2020
5.0.7 101,018 4/14/2020
5.0.5 72,783 3/26/2020
5.0.4 35,288 3/12/2020
5.0.3 23,254 2/21/2020
5.0.2 19,663 2/10/2020
5.0.1 21,381 2/3/2020
5.0.0-rc 3,165 1/19/2020
5.0.0-beta 14,109 10/29/2019
5.0.0-alpha2 10,298 9/24/2019
5.0.0-alpha 9,711 8/4/2019
4.1.4 3,945,952 6/11/2018
4.1.3 33,436 5/28/2018
4.1.2 200,770 3/11/2018
4.1.1 88,493 1/8/2018
4.1.0 36,585 12/17/2017
4.0.0 57,065 10/18/2017
4.0.0-beta2 3,096 10/2/2017
4.0.0-beta1 10,583 8/28/2017
3.1.5 54,256 3/17/2018
3.1.4 133,287 8/16/2017
3.1.3 5,455 8/13/2017
3.1.2 5,487 8/4/2017
3.1.1 25,290 6/8/2017
3.1.0 106,504 3/11/2017
3.0.1 10,195 2/15/2017
3.0.0 18,773 1/20/2017
3.0.0-beta3 7,255 12/25/2016
3.0.0-beta2 3,617 11/27/2016
3.0.0-beta 2,222 11/20/2016
2.0.4 58,780 11/7/2016
2.0.2 51,962 8/25/2016
2.0.1 3,015 8/22/2016
2.0.0 5,320 7/31/2016
2.0.0-rc2 2,300 7/20/2016
2.0.0-rc 16,466 12/24/2015
2.0.0-beta 2,251 11/20/2015
1.0.5 9,108 7/23/2016
1.0.4 19,670 10/26/2015
1.0.3 7,084 9/6/2015
1.0.2 4,556 5/17/2015
1.0.1 2,423 5/11/2015
1.0.0 3,677 3/28/2015
0.9.0 3,188 2/5/2015
0.8.0 2,696 1/31/2015
0.6.0 2,808 1/20/2015
0.5.0 3,220 8/25/2014