Adam Laycock


Featured Posts

Moving to Gatsby

4th December 2018

Ive moved my site over to Gatsby!

Everything an Option in the Theme

18th August 2016

My aproach to WordPress theme development.

RADIUS With Windows Server 2012R2

22nd July 2016

RADIUS authentication for wireless networks using NAP in Windows Server 2012R2.


14th July 2015

  • 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:

sodb = require 'sodb'

db = new sodb()

Which can now have objects added to it

db.add {name: 'bob', age: 10, height: 120}

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:

db.where {name: 'bob'}
db.where {name {is: 'bob'}} # this is the same as the line above, sodb assumes you mean is
db.where {age: {gt: 8}}
db.where {age: {lt: 12}}
db.where {name: {isnot: 'steve'}}

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

db.where {name: 'bob'}, {age: {gt: 8}}

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

db.where {name: ['bob', 'kevin']}

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:

db.where {route: '/foo/bar'}, {method: ['get', 'all']}

Other Posts

Caching Apple Downloads

14th July 2015

Solving the worst part of iPads in schools.

Caching Apple downloads on a Windows server

15th July 2015

Following my recent post I look at how to implement Apple caching on a Windows server.

Adam Laycock
Recent Articles

All content is my own unless otherwise stated.

My content is licensed under the CC-BY-NC-SA 4.0 license

cc by-nc-sa