lib/dataset/actions.js
function (includeColumnTitles, cb) {
            var n = this.naked();
            if (isFunction(includeColumnTitles)) {
                cb = includeColumnTitles;
                includeColumnTitles = true;
            }
            includeColumnTitles = isBoolean(includeColumnTitles) ? includeColumnTitles : true;
            return n.columns.chain(function (cols) {
                var vals = [];
                if (includeColumnTitles) {
                    vals.push(cols.join(", "));
                }
                return n.forEach(function (r) {
                    vals.push(cols.map(function (c) {
                        return r[c] || "";
                    }).join(", "));
                }).chain(function () {
                    return vals.join("\r\n") + "\r\n";
                });
            }.bind(this)).classic(cb).promise();
        }
function (includeColumnTitles, cb) {
            var n = this.naked();
            if (isFunction(includeColumnTitles)) {
                cb = includeColumnTitles;
                includeColumnTitles = true;
            }
            includeColumnTitles = isBoolean(includeColumnTitles) ? includeColumnTitles : true;
            return n.columns.chain(function (cols) {
                var vals = [];
                if (includeColumnTitles) {
                    vals.push(cols.join(", "));
                }
                return n.forEach(function (r) {
                    vals.push(cols.map(function (c) {
                        return r[c] || "";
                    }).join(", "));
                }).chain(function () {
                    return vals.join("\r\n") + "\r\n";
                });
            }.bind(this)).classic(cb).promise();
        }
function ( includeColumnTitles , cb ) { var n = this . naked ( ) ; if ( isFunction ( includeColumnTitles ) ) { cb = includeColumnTitles ; includeColumnTitles = true ; } includeColumnTitles = isBoolean ( includeColumnTitles ) ? includeColumnTitles : true ; return n . columns . chain ( function ( cols ) { var vals = [ ] ; if ( includeColumnTitles ) { vals . push ( cols . join ( ", " ) ) ; } return n . forEach ( function ( r ) { vals . push ( cols . map ( function ( c ) { return r [ c ] || "" ; } ) . join ( ", " ) ) ; } ) . chain ( function ( ) { return vals . join ( "\r\n" ) + "\r\n" ; } ) ; } . bind ( this ) ) . classic ( cb ) . promise ( ) ; }
Returns a promise resolved with a string in CSV format containing the dataset records. By
default the CSV representation includes the column titles in the
first line. You can turn that off by passing false as the
includeColumnTitles argument.

<p>
<b>NOTE:</b> This does not use a CSV library or handle quoting of values in
any way.  If any values in any of the rows could include commas or line
endings, you shouldn't use this.
</p>

@example
// SELECT * FROM table
DB.from("table").toCsv().chain(function(csv){
console.log(csv);
//outputs
id,name
1,Jim
2,Bob
});

// SELECT * FROM table
DB.from("table").toCsv(false).chain(function(csv){
console.log(csv);
//outputs
1,Jim
2,Bob
});

@param {Boolean} [includeColumnTitles=true] Set to false to prevent the printing of the column
titles as the first line.

@param {Function} [cb] the callback to invoke when the action is done.

@return {comb.Promise} a promise that will be resolved with the CSV string of the results of the
query.
Returns a promise resolved with a string in CSV format containing the dataset records . By default the CSV representation includes the column titles in the first line . You can turn that off by passing false as the includeColumnTitles argument .