goodybag/mongo-sql — pull request #5 by jrf0110 (2013-05-12 23:59:54+00:00)
Title: Make interface more declarative

Originally, mongo-pg and mongo-sql we're the same libraries. Mongo-Sql resembles the early muck of the imperative style:

```javascript
find($query, options)
```

But this is no longer really needed. This is just a sql generator for JSON. Let's move to this syntax:

```javascript
{
type: 'select'

, columns: [ '*', 'extension.field1', 'extension.field2' ]

, tables: [ 'users', 'extension' ]

, joins: {
leftJoin: {
extension: { id: 'extension.id' }
}
}

, where: {
name: { $ilike: 'bob', $or: { $ilike: 'alice' } }
, id: {
$nin: {
type: 'select'
, columns: 'id'
, table: 'otherUsers'
, where: { someCondition: true }
}
}
}

, limit: 100

, order: { id: 'desc' }

, groupBy: ['id', 'name']
}
```

Where each top-level property corresponds with a field in the base query:

```sql
select {fields} from {collections} {joins} {where} {limit} {order} {groupBy}
```

And each field also corresponds to a builder function.

In this way, you would be able to write custom query types more easily.