MonoDS is a local NoSQL Document Storage Database for use with Xamarin iOS and Android. With MonoDS you can store and retrieve domain objects without creating database tables and mapping code.
- Fast performance.
- No unmanaged dependancies (Completely written in C# .NET).
- No need to create database tables or mapping code.
- Data files are kept small by allowing room for growth in the data file. By default all documents are padded with 50% extra space so that updates to a document do not require a new record at the end of the data file. Deleted documents are overwritten by new documents in the data file.
- Download the MonoDS.dll and Newtonsoft.dll from the Build folder.
- Add the two DLL files as references to your project.
- The current API is very small. See the code sample's below for available methods:
using System;
using System.IO;
using MonoDS;
public class Person
{
public int Id {get; set;} // Required
public string Name {get; set;}
public string Email {get; set;}
}
// get the path to the library folder in iOS
var documentsPath = Environment.GetFolderPath (Environment.SpecialFolder.MyDocuments);
var libraryPath = Path.Combine (documentsPath, "..", "Library");
// store
using (var docStore = new DocumentStore(libraryPath))
{
var person = new Person() { Name = "MonoDS", Email = "[email protected]" };
docStore.Store<Person>(person);
Console.WriteLine(person.Id);
}
// load
using (var docStore = new DocumentStore(libraryPath))
{
docStore.Find<Person>(1);
Console.WriteLine(person.Name);
}
// update
using (var docStore = new DocumentStore(libraryPath))
{
var person = docStore.Find<Person>(1);
person.Name = "MonoDS Changed";
docStore.Update<Person>(person);
}
// delete
using (var docStore = new DocumentStore(libraryPath))
{
docStore.Delete<Person>(1);
}
// get all
using (var docStore = new DocumentStore(libraryPath))
{
docStore.Store<Person>(new Person() { Name = "MonoDS", Email = "[email protected]" });
docStore.Store<Person>(new Person() { Name = "MonoDS2", Email = "[email protected]" });
var persons = docStore.All<Person>(1);
foreach(var person in persons){
Console.WriteLine(person.Name);
}
}
// count
using (var docStore = new DocumentStore(libraryPath))
{
var count = docStore.Count<Person>();
Console.WriteLine(count);
}
- Domain objects must have an Id property and it must be a short, int or long.
- Built and tested on iOS using Xamarin Studio.
- Unit tests show around 5x faster insert performance than Sqlite for 10,000 documents.
- Autoincrement is faster than specifying a key value because lookups are faster with no duplicate checks.
- Support Querys as currently all documents of a certain type need loaded and sorted using LINQ.
- Change tracking and Unit of Work.
- Handle power failures and crashes using transaction logging.
For bugs and feature requests please open a new issue.
- MonoDS is used in the free weight lifting app MyStrength.
- Freely distributable under the terms of the MIT License
- MIT License allows the library to be used in Apps published to the App store's.