UltraLiteDB is a trimmed down version of LiteDB 4.0 (http://www.litedb.org). Anything that needs Linq or dynamic code generation has been removed to make it work in Unity's IL2CPP AoT runtime environment. Some additional features have been removed to reduce code footprint. What's left is a very small, fast key-value store that lets you save and load BSON-encoded data in any Unity environment.
Major features missing from LiteDBThis is a great library to use for any project that needs to store lots of mutable data in a convenient and accessible way. For example:
It could also be useful for large amounts of read-only data as well, where you need to locate records in a data-file too large to keep in memory all the time:
For basic CRUD operations, the LiteDB documentation largely applies to UltraLiteDB.
The biggest difference is that any query or index method using a linq expression method are missing.
Installing in a Unity projectDownload the UltraLiteDB.dll from the Releases page and put it in the ./Assets/Plugins folder of your Unity project. That should be it!
A quick example for storing and searching documents:
using UltraLiteDB; void DatabaseTest() { // Open database (or create if doesn't exist) var db = new UltraLiteDatabase("MyData.db") // Get a collection var col = db.GetCollection("savegames"); // Create a new character document var character = new BsonDocument(); character["Name"] = "John Doe"; character["Equipment"] = new string[] { "sword", "gnome hat" }; character["Level"] = 1; character["IsActive"] = true; // Insert new customer document (Id will be auto generated) BsonValue id = col.Insert(character); // new Id has also been added to the document at character["_id"] // Update a document inside a collection character["Name"] = "Joana Doe"; col.Update(character); // Insert a document with a manually chosen Id var character2 = new BsonDocument(); character2["_id"] = 10; character2["Name"] = "Test Bob"; character2["Level"] = 10; character2["IsActive"] = true; col.Insert(character2); // Load all documents List<BsonDocument> allCharacters = new List<BsonDocument>(characters.FindAll()); // Delete something col.Delete(10); // Upsert (Update if present or insert if not) col.Upsert(character); // Don't forget to cleanup! db.Dispose(); }
The BsonDocument class generates garbage every time you load or save to the database. I'm investigating allowing custom allocators and object reuse pools to reduce garbage generation from load and save operations. I don't think this library can be made 100% garbage free, but there is currently much room for improvement.
To build UltraLiteDB yourself:
Copyright (c) 2017 - MaurĂcio David
This project is entirely built upon MaurĂcio David's excellent LiteDB, and would not exist without it.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4