Add better syntax for non-parameterized values in condition builder
The current syntax is to wrap the value in dollars. I think maybe making this double dollar would be good as postgres already supports this. However, It fucks up your value. It becomes a chore to check query.joins.group.id == '$otherTable.id' rather than simply query.joins.group.id === 'otherTable.id'
I thought about making a global property that will say, hey any descendents of me do not get parameterized. That syntax would look like:
var query = {
type: 'select'
, table: ['users', 'groups']
, where: {
$: { 'users.id': 'groups.userId' }
, 'groups.name': 'admin'
}
};
While this cleans the syntax a bit, it becomes just as difficult, if not harder to reason about. You would be like, query.where['users.id'] thinking you would find it.. but you don't know what objects are going to have a $ property.
Maybe we could have a completely separate where clause:
var query = {
type: 'select'
, table: ['users', 'groups']
// Not parameterized
, $where: {
'users.id': 'groups.userId'
}
// Parameterized
, where: {
'groups.name': 'admin'
}
};
Maaayyyybe something like:
var query = {
type: 'select'
, table: ['users', 'groups']
, where: {
'users.id': mosql.$('groups.userId')
, 'groups.name': 'admin'
}
};
Or:
where: {
'users.id': { $eqfield: 'groups.userId' }
}