umitanuki/mongres

SQL in Mongo Discussion

jrf0110 opened this issue · 0 comments

I'm sure a number of people have treaded the waters of making a mongo-like API for interacting with SQL, myself included. Basic API replication is really easy of course, but then you realize that there's a huge void of SQL features simply missing (Joins, sub-queries, aliased queries, etc.). Once you start implementing those, your API starts diverging greatly from mongo.

I think my implementation of MongoSQL could help out a lot. I've got a ton of features implemented and it's incredibly extensible. I don't really have the Docs fleshed out yet, but you can skim the readme, tests, and helpers to get an idea of the capabilities.

Originally, MongoSQL's goal was to mimic Mongo as much as possible. But it's evolved to just writing arbitrary SQL using JSON. One thing to note is MongoSQL's querying capability is very robust. You can arbitrarily embed conditions in the style of mongo:

var $query = {
  type: 'select'
, table: 'users'
, where: {
    createdAt: {
      $or: {
        $gt: '2013-01-01'
      , $lt: '2012-01-01'
      }
    }
  , id: {
      // Id not in
      $nin: {
        type: 'select'
      , table: 'deletedUsers'
      , columns: ['id']
      }
    }
  }
};

Just a thought :)