https://github.com/kalilistic/litehelper
A helper library for working with LiteDB.
https://github.com/kalilistic/litehelper
litedb
Last synced: 2 months ago
JSON representation
A helper library for working with LiteDB.
- Host: GitHub
- URL: https://github.com/kalilistic/litehelper
- Owner: kalilistic
- License: mit
- Created: 2023-04-03T23:55:36.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2023-09-08T22:53:22.000Z (over 1 year ago)
- Last Synced: 2025-01-08T01:38:34.138Z (4 months ago)
- Topics: litedb
- Language: C#
- Homepage:
- Size: 55.7 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# LiteHelper
[](https://www.nuget.org/packages/LiteHelper/)A small helper library to use with [LiteDB](https://github.com/mbdavid/LiteDB).
## Features
- Provide BsonCollectionAttribute to get and set collection names
- Provide CustomBsonMapper with sensible defaults and support for more data types
- Provide BsonDocumentExtensions for dynamic key and value retrieval
- Provide Factory pattern for easier building of LiteDB instances
- Provide Record with comparer for easier implementation of persistence## Example
```csharp
using var dbFactory = new LiteDatabaseFactory("D:\databaseDir", "db", "direct");
ILiteCollection collection = dbFactory.Database.GetCollection("MyCollection");
if (collection != null)
{
var documents = collection.FindAll().ToList();
if (documents.Count > 0)
{
var document = documents.First();
var name = document.GetValueOrDefault("Name");
}
}
```