lib/sql.js
function(collectionName, collection, fn, separator, keyOverride, parentKey) {
        separator = separator || ', ';
        var $sql = '';
        _.each(collection, function(value, key) {
            $sql += fn(collectionName, value, keyOverride || key, parentKey);

            // (always append separator)
            $sql += separator;
        });

        // (then remove final one)
        return _.str.rtrim($sql, separator);
    }
function(collectionName, collection, fn, separator, keyOverride, parentKey) {
        separator = separator || ', ';
        var $sql = '';
        _.each(collection, function(value, key) {
            $sql += fn(collectionName, value, keyOverride || key, parentKey);

            // (always append separator)
            $sql += separator;
        });

        // (then remove final one)
        return _.str.rtrim($sql, separator);
    }
Put together the CSV aggregation separator => optional, defaults to ', ' keyOverride => optional, overrides the keys in the dictionary (used for generating value lists in IN queries) parentKey => key of the parent to this object