SODB

sodb is the latest of my little projects to hit npm and I really enjoyed making this one.

It is written in coffee-script and fully tested.

The idea is to have the features of a database table available to an array of objects. You have to admit that {name: 'bob', age: 10, height: 120} already looks a lot like a database record so that is all sodb needs to add a record!

Creating a database is as easy as creating a new object:

Which can now have objects added to it

The database now has 1 entry in it which can be searched for (not that you need to) and updated or removed when ever you want.

Finding records is done through the where method which takes varying arguments like so:

You can have multiple searches which are run one after another on an ever decreasing set of the results.

If you need to find records where X is a or b you can use:

sodb also features a cache to help speed up the finding of data in large databases, or to be more specific finding the same data again in a large database.

Caching uses a hash of of the search object(s) to store the returned results and then returns them to you if they exist.

sodb was written for an as yet unreleased version of express-permissions which needed the permissions to be stored where I could run a query like:

Adam Laycock

IT Engineer and Developer working in education. I try to do everything in my power to create better systems for schools be it the windows domain or a plugin for their WordPress site.

Leave a Reply

Your email address will not be published. Required fields are marked *