Mongo Legacy ObjectIDs
As more projects recognize the value that some alternate data storage engines can provide over relational databases, one has to pause on some of the migrations. Although you may end up with an entity in Mongo that has the same basic concept as in a RDBMS like MySQL, if you had an API or exposed the id’s previously, you might want to have a compatibility layer.
So what might some examples be? Take for example most typical Rails applications. The ID of the resource is exposed in the url. Conceptually this isn’t a problem, as when you move to Mongo, you often keep the same paradigm. Except, that in Mongo, the ID is actually an ObjectID, not an integer as typical Rails RDBMS dictates. So you might have the url look like http://my_domain_name/resource/1d24974db613c47d04000000
The old url may have been http://my_domain_name/resource/73472. Keeping a consistent mechanism to query your DB becomes difficult with these old resources unless you stored them as plain IDs, which means now you have to either query for an ID as 73472, or an ObjectID(“1d24974db613c47d04000000”)
What if we could simplify this, so that we always query for an ObjectID. What if we could generate the 24 byte string that makes up an ObjectID from any integer legacy ID? Look at this Ruby snippet:
This could be used to convert the legacy ids and generate the new ObjectIDs for the documents you make to replace each row from your legacy DB.
On read, you can run any ID thru this code to check to see if the id is 24 characters & if not, it will convert it to an ObjectID format hex. The code is based heavily on the Ruby Driver code to create ObjectIDs, but replaces the first several bytes with the string LEGACY_ID.
How I came to get the 11” MacBook Air
I work professionally as a developer. I always get new hardware. As machines have been getting lighter & faster, I’ve always sought out a way to lighten the load when I’m on the go but still be productive. Eventually that led me to get the 11” MacBook Air.
OmniFocus for iPad first impressions
It’s been a long wait, but OmniFocus for iPad was finally let loose on the App Store today. So, what is there to expect from the newest member of the OmniFocus family?
AREL for APIs
One of the most exciting features of Rails 3 is ActiveRelation. Simply put, this lets you do chained scopes for any SQL command.
Lighthouse gets a calendar
A lot of software projects use Lighthouse to manage their project. It’s good…. but missing a calendar.
Pivotal Tracker add ons
I’ve been using Pivotal Tracker daily for the past week or so. For the most part, I really like it. However, sometimes I don’t want to have to load up PivotalTracker to have a sense of what is upcoming as I’m managing a project.