Skip to content

Instantly share code, notes, and snippets.

@rofr
Created September 17, 2014 03:16
Show Gist options
  • Select an option

  • Save rofr/d54e7b89947ff9ffc5dd to your computer and use it in GitHub Desktop.

Select an option

Save rofr/d54e7b89947ff9ffc5dd to your computer and use it in GitHub Desktop.
OrigoDB Document database engine wrapper
public class DocumentDatabaseEngine
{
private readonly Engine<DocumentModel> _engine;
public DocumentDatabaseEngine(string location)
{
_engine = Engine.LoadOrCreate<DocumentModel>(location);
}
public DocumentDatabaseEngine() : this(String.Empty)
{ }
public object Get(object key)
{
return _engine.Execute(db => db.Get(key));
}
public T Get<T>(object key)
{
return _engine.Execute(db => db.Get<T>(key));
}
public T Get<T>(Func<Dictionary<object,object>,T> query )
{
return _engine.Execute(db => db.ExecuteQuery(query));
}
public void Put(object key, object document)
{
var command = new PutCommand(key, document);
_engine.Execute(command);
}
public bool Remove(object key)
{
var command = new RemoveCommand(key);
return _engine.Execute(command);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment