A simpler way to use LiteDB
Add as reference
using LiteDB.Wrapper;
using LiteDB.Wrapper.Interface;
Create a collection reference
ICollectionRef<YourModel> reference = new CollectionReference<YourModel>("mydatabase.db", "my_collection");
Available methods
Insert(T)
Insert(IList<T>)
Update(T)
Update(IList<T>)
Remove(Guid)
Remove(IList<Guid>)
Commit()
Get(Guid)
GetPaged(PageOptions, SortOptions)
Here's an example usage
ICollectionRef<Model> reference = new CollectionReference<Model>(litedbloc, "insert_collection");
reference.Insert(new Model
{
_ID = Guid.NewGuid(),
Word = "Sample Word",
Number = 99
});
await reference.Commit();
You have to invoke Commit()
at the end to save your changes to LiteDB
.
Note : As per LiteDB
specs, you must decorate your model classes with BsonField
attributes.
Install the following to get started
IDE
Exntesions
Frameworks
Do you want to contribute? Send me an email or DM me in twitter.