-
Notifications
You must be signed in to change notification settings - Fork 2
Story
A KiwiDB database is called a collection and each collection has a single database file on disk.
var collection = new Collection(@"c:\temp\data.kiwidb");
Instatiating a collection really does nothin in itself, and the file name and extension is totally of your choice.
Now lets put stuff in the collection. And by stuff we mean plain old .NET objects, also called documents in the Nosql world. The documents you can put in a collection can have any combination of lists, classes, dictionaries and simple values. The only requirement is that the stuff you put in must be serializable to and deserializable from Json.
Also, each document is associated via a key. This is not negotiable.
Currently
- keys are always strings
- keys are case sensitive
- keys are not part of the data, and this is an important difference compared to, say, MongoDB
- keys are always created by the application, never by KiwiDB
Ok, lets insert our friend Jane Doe in to the collection.
collection.Update("JaneDoe", new { FirstName = "Jane", LastName = "Doe", Relation = "Friend" });Here, we used "JaneDoe" as a key for the structured document describing out friend.
The years passes... ...and one sunny day we find ourself happily married with kids. Lets make a note of it.
collection.Update("JaneDoe", new { FirstName = "Jane", LastName = "Doe", Relation = "Married" });Using the same old key, "JaneDoe", we could overwrite the old document and replace it with a new one.
Lets hope for a long happy marriage so we dont ever, never have to
collection.Remove("JaneDoe");Dusky autumn evening when we are feeling sentimental, we can easily remember old acquaintances with
dearOldFriends = collection.Find(new {Relation = "Friend"});A long and fully lived life just might motivate a speedup of that operation.
collection.EnsureIndex("Relation");