Code Monkey home page Code Monkey logo

microdocumentdatabase's Introduction

MicroDocumentDatabase

Ever had the need for a small database no fuss nothing complicated just a simple way to store and retreive information when the computer has been reset, welcome to MicroDocumentDatabase.

This database storage system can be better described as a document type storage system there is no relationship querying like with a conventional databases, MySQL or MSSQL.

Unlike with normal databases you dont have to setup a server to operate this service, it just sits in the local directory and is easy to create, no need to handle complicated querys.

You can compare a table in a normal database as an instance in this one, it also uses the type of the class as part of the filename so you can keep multiple instances of data stored in a directory.

You can use any class you like just tell the database the type when you create the instance of the database.

var db = new DocumentDriver<MyClassNameHere>();
// if you use the data at the end of the readme as temp testing data you will see a filename like this once you have saved it.
// class is called Doc

var db = new DocumentDriver<Doc>();
db.Save();

// looks like this in the filesystem
MicroDatabase_Doc.data

Once your have created your database instance you can add to it very easily.

db.Add(new Doc { id = "a", name = "Jon", content = "blah blah blah in a record", description = "asdasdasdasd", guid = Guid.NewGuid(), created = DateTime.Now });

Handling data just got easy just use one of the built in commands

// Save from memory to the filesystem
db.Dump();

// Load to memory from the filesystem
db.Load();

// Get a file from memory
var record = db.Get("b");

// Update
var rec = new Doc { id = "b", name = "Jon", content = "stuff in a record", description = "This is the new information", guid = Guid.NewGuid(), created = DateTime.Now };
db.Update("b", rec);

// Delete
db.Delete("b");

its not complicated just have a play around to handle your data. You can modify the code if you want more flexability as the library is very small.

Support

Any problems let me know, feel free to use this code in any way you like if u break it you buy it :D

Final thoughts - maybe to help with performance ill release a binary serealiser which would be faster but harder to work with. This library is very easy to keep track of your mistakes as you can look at everything as it all in text even the datastored is in plain text.

Test data for you to play around with

db.Add(new Doc { id = "a", name = "Jon", content = "blah blah blah in a record", description = "asdasdasdasd", guid = Guid.NewGuid(), created = DateTime.Now });
db.Add(new Doc { id = "b", name = "Jon", content = "blah blah blah in a record", description = "asdasdasdasd", guid = Guid.NewGuid(), created = DateTime.Now });
db.Add(new Doc { id = "c", name = "Steve", content = "blah blah blah in a record", description = "asdadadadsadsad", guid = Guid.NewGuid(), created = DateTime.Now });
db.Add(new Doc { id = "d", name = "Frank", content = "blah blah blah in a record", description = "asddsadadadsadad", guid = Guid.NewGuid(), created = DateTime.Now });
db.Add(new Doc { id = "e", name = "Bobby", content = "blah blah blah in a record", description = "adsasdasdsadasdads", guid = Guid.NewGuid(), created = DateTime.Now });
db.Add(new Doc { id = "f", name = "Simon", content = "blah blah blah in a record", description = "asdasdsadadsadas", guid = Guid.NewGuid(), created = DateTime.Now });
db.Add(new Doc { id = "fs", name = "Jimmy", content = "blah blah blah in a record", description = "asdasdasdasdasdasd", guid = Guid.NewGuid(), created = DateTime.Now });
db.Add(new Doc { id = "a", name = "Jon", content = "blah blah blah in a record", description = "asdasdasdasd", guid = Guid.NewGuid(), created = DateTime.Now });
db.Add(new Doc { id = "b", name = "Steve", content = "blah blah blah in a record", description = "asdadadadsadsad", guid = Guid.NewGuid(), created = DateTime.Now });
db.Add(new Doc { id = "c", name = "Frank", content = "blah blah blah in a record", description = "asddsadadadsadad", guid = Guid.NewGuid(), created = DateTime.Now });
db.Add(new Doc { id = "d", name = "Bobby", content = "blah blah blah in a record", description = "adsasdasdsadasdads", guid = Guid.NewGuid(), created = DateTime.Now });
db.Add(new Doc { id = "e", name = "Simon", content = "blah blah blah in a record", description = "asdasdsadadsadas", guid = Guid.NewGuid(), created = DateTime.Now });
db.Add(new Doc { id = "f", name = "Jimmy", content = "blah blah blah in a record", description = "asdasdasdasdasdasd", guid = Guid.NewGuid(), created = DateTime.Now });
db.Add(new Doc { id = "a", name = "Jon", content = "blah blah blah in a record", description = "asdasdasdasd", guid = Guid.NewGuid(), created = DateTime.Now });
db.Add(new Doc { id = "b", name = "Steve", content = "blah blah blah in a record", description = "asdadadadsadsad", guid = Guid.NewGuid(), created = DateTime.Now });
db.Add(new Doc { id = "c", name = "Frank", content = "blah blah blah in a record", description = "asddsadadadsadad", guid = Guid.NewGuid(), created = DateTime.Now });
db.Add(new Doc { id = "d", name = "Bobby", content = "blah blah blah in a record", description = "adsasdasdsadasdads", guid = Guid.NewGuid(), created = DateTime.Now });
db.Add(new Doc { id = "e", name = "Simon", content = "blah blah blah in a record", description = "asdasdsadadsadas", guid = Guid.NewGuid(), created = DateTime.Now });
db.Add(new Doc { id = "f", name = "Jimmy", content = "blah blah blah in a record", description = "asdasdasdasdasdasd", guid = Guid.NewGuid(), created = DateTime.Now });
db.Add(new Doc { id = "a", name = "Jon", content = "blah blah blah in a record", description = "asdasdasdasd", guid = Guid.NewGuid(), created = DateTime.Now });
db.Add(new Doc { id = "b", name = "Steve", content = "blah blah blah in a record", description = "asdadadadsadsad", guid = Guid.NewGuid(), created = DateTime.Now });
db.Add(new Doc { id = "c", name = "Frank", content = "blah blah blah in a record", description = "asddsadadadsadad", guid = Guid.NewGuid(), created = DateTime.Now });
db.Add(new Doc { id = "d", name = "Bobby", content = "blah blah blah in a record", description = "adsasdasdsadasdads", guid = Guid.NewGuid(), created = DateTime.Now });
db.Add(new Doc { id = "e", name = "Simon", content = "blah blah blah in a record", description = "asdasdsadadsadas", guid = Guid.NewGuid(), created = DateTime.Now });
db.Add(new Doc { id = "f", name = "Jimmy", content = "blah blah blah in a record", description = "asdasdasdasdasdasd", guid = Guid.NewGuid(), created = DateTime.Now });
db.Add(new Doc { id = "f", name = "Jimmy", content = "blah blah blah in a record", description = "asdasdasdasdasdasd", guid = Guid.NewGuid(), created = DateTime.Now });
db.Add(new Doc { id = "a", name = "Jon", content = "blah blah blah in a record", description = "asdasdasdasd", guid = Guid.NewGuid(), created = DateTime.Now });
db.Add(new Doc { id = "b", name = "Jon", content = "blah blah blah in a record", description = "asdasdasdasd", guid = Guid.NewGuid(), created = DateTime.Now });
db.Add(new Doc { id = "c", name = "Steve", content = "blah blah blah in a record", description = "asdadadadsadsad", guid = Guid.NewGuid(), created = DateTime.Now });
db.Add(new Doc { id = "d", name = "Frank", content = "blah blah blah in a record", description = "asddsadadadsadad", guid = Guid.NewGuid(), created = DateTime.Now });
db.Add(new Doc { id = "e", name = "Bobby", content = "blah blah blah in a record", description = "adsasdasdsadasdads", guid = Guid.NewGuid(), created = DateTime.Now });
db.Add(new Doc { id = "f", name = "Simon", content = "blah blah blah in a record", description = "asdasdsadadsadas", guid = Guid.NewGuid(), created = DateTime.Now });
db.Add(new Doc { id = "fs", name = "Jimmy", content = "blah blah blah in a record", description = "asdasdasdasdasdasd", guid = Guid.NewGuid(), created = DateTime.Now });
db.Add(new Doc { id = "a", name = "Jon", content = "blah blah blah in a record", description = "asdasdasdasd", guid = Guid.NewGuid(), created = DateTime.Now });
db.Add(new Doc { id = "b", name = "Steve", content = "blah blah blah in a record", description = "asdadadadsadsad", guid = Guid.NewGuid(), created = DateTime.Now });
db.Add(new Doc { id = "c", name = "Frank", content = "blah blah blah in a record", description = "asddsadadadsadad", guid = Guid.NewGuid(), created = DateTime.Now });
db.Add(new Doc { id = "d", name = "Bobby", content = "blah blah blah in a record", description = "adsasdasdsadasdads", guid = Guid.NewGuid(), created = DateTime.Now });
db.Add(new Doc { id = "e", name = "Simon", content = "blah blah blah in a record", description = "asdasdsadadsadas", guid = Guid.NewGuid(), created = DateTime.Now });
db.Add(new Doc { id = "f", name = "Jimmy", content = "blah blah blah in a record", description = "asdasdasdasdasdasd", guid = Guid.NewGuid(), created = DateTime.Now });
db.Add(new Doc { id = "a", name = "Jon", content = "blah blah blah in a record", description = "asdasdasdasd", guid = Guid.NewGuid(), created = DateTime.Now });
db.Add(new Doc { id = "b", name = "Steve", content = "blah blah blah in a record", description = "asdadadadsadsad", guid = Guid.NewGuid(), created = DateTime.Now });
db.Add(new Doc { id = "c", name = "Frank", content = "blah blah blah in a record", description = "asddsadadadsadad", guid = Guid.NewGuid(), created = DateTime.Now });
db.Add(new Doc { id = "d", name = "Bobby", content = "blah blah blah in a record", description = "adsasdasdsadasdads", guid = Guid.NewGuid(), created = DateTime.Now });
db.Add(new Doc { id = "e", name = "Simon", content = "blah blah blah in a record", description = "asdasdsadadsadas", guid = Guid.NewGuid(), created = DateTime.Now });
db.Add(new Doc { id = "f", name = "Jimmy", content = "blah blah blah in a record", description = "asdasdasdasdasdasd", guid = Guid.NewGuid(), created = DateTime.Now });
db.Add(new Doc { id = "a", name = "Jon", content = "blah blah blah in a record", description = "asdasdasdasd", guid = Guid.NewGuid(), created = DateTime.Now });
db.Add(new Doc { id = "b", name = "Steve", content = "blah blah blah in a record", description = "asdadadadsadsad", guid = Guid.NewGuid(), created = DateTime.Now });
db.Add(new Doc { id = "c", name = "Frank", content = "blah blah blah in a record", description = "asddsadadadsadad", guid = Guid.NewGuid(), created = DateTime.Now });
db.Add(new Doc { id = "d", name = "Bobby", content = "blah blah blah in a record", description = "adsasdasdsadasdads", guid = Guid.NewGuid(), created = DateTime.Now });
db.Add(new Doc { id = "e", name = "Simon", content = "blah blah blah in a record", description = "asdasdsadadsadas", guid = Guid.NewGuid(), created = DateTime.Now });
db.Add(new Doc { id = "f", name = "Jimmy", content = "blah blah blah in a record", description = "asdasdasdasdasdasd", guid = Guid.NewGuid(), created = DateTime.Now });
db.Add(new Doc { id = "f", name = "Jimmy", content = "blah blah blah in a record", description = "asdasdasdasdasdasd", guid = Guid.NewGuid(), created = DateTime.Now });

microdocumentdatabase's People

Contributors

ijsworkshop avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.