Created
September 17, 2014 03:12
-
-
Save rofr/eeac5c0390101b97783a to your computer and use it in GitHub Desktop.
Naive OrigoDB document database model
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [Serializable] | |
| public class DocumentModel : Model | |
| { | |
| private readonly Dictionary<object,object> _documents; | |
| public DocumentModel() | |
| { | |
| _documents = new Dictionary<object, object>(); | |
| } | |
| public T Get<T>(object key) | |
| { | |
| return (T) Get(key); | |
| } | |
| public object Get(object key) | |
| { | |
| return _documents.ContainsKey(key) ? _documents[key] : null; | |
| } | |
| public void Put(object key, object document) | |
| { | |
| _documents[key] = document; | |
| } | |
| public bool Remove(object key) | |
| { | |
| return _documents.Remove(key); | |
| } | |
| public T ExecuteQuery<T>(Func<Dictionary<object, object>, T> query) | |
| { | |
| return query.Invoke(_documents); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment