index.js
function find_props(schema) {

    var props = _(schema.paths).keys().without('_id', 'id')

        // transform the schema tree into an array for filtering
        .map(function(key) { return { name : key, value : _.get(schema.tree, key) }; })

        // remove paths that are annotated with csv: false
        .filter(function(node) {
            return typeof node.value.csv === 'undefined' || node.value.csv;
        })

        // remove virtuals that are annotated with csv: false
        .filter(function(node) {
            var opts = node.value.options;
            if (!opts) return true;
            return typeof opts.csv === 'undefined' || opts.csv;
        })

        // remove complex object types
        .filter(function(node) {
            var path = schema.paths[node.name];
            if (!path) return true;
            // filter out any of these types of properties
            return [ 'Array', 'Object', 'Mixed' ].indexOf(path.instance) === -1;
        })

        // materialize , end chain
        .pluck('name').value();

    // _id at the beginning
    props.unshift('_id');

    return props;
}
function find_props(schema) {

    var props = _(schema.paths).keys().without('_id', 'id')

        // transform the schema tree into an array for filtering
        .map(function(key) { return { name : key, value : _.get(schema.tree, key) }; })

        // remove paths that are annotated with csv: false
        .filter(function(node) {
            return typeof node.value.csv === 'undefined' || node.value.csv;
        })

        // remove virtuals that are annotated with csv: false
        .filter(function(node) {
            var opts = node.value.options;
            if (!opts) return true;
            return typeof opts.csv === 'undefined' || opts.csv;
        })

        // remove complex object types
        .filter(function(node) {
            var path = schema.paths[node.name];
            if (!path) return true;
            // filter out any of these types of properties
            return [ 'Array', 'Object', 'Mixed' ].indexOf(path.instance) === -1;
        })

        // materialize , end chain
        .pluck('name').value();

    // _id at the beginning
    props.unshift('_id');

    return props;
}
function find_props ( schema ) { var props = _ ( schema . paths ) . keys ( ) . without ( '_id' , 'id' ) // transform the schema tree into an array for filtering . map ( function ( key ) { return { name : key , value : _ . get ( schema . tree , key ) } ; } ) // remove paths that are annotated with csv: false . filter ( function ( node ) { return typeof node . value . csv === 'undefined' || node . value . csv ; } ) // remove virtuals that are annotated with csv: false . filter ( function ( node ) { var opts = node . value . options ; if ( ! opts ) return true ; return typeof opts . csv === 'undefined' || opts . csv ; } ) // remove complex object types . filter ( function ( node ) { var path = schema . paths [ node . name ] ; if ( ! path ) return true ; // filter out any of these types of properties return [ 'Array' , 'Object' , 'Mixed' ] . indexOf ( path . instance ) === - 1 ; } ) // materialize , end chain . pluck ( 'name' ) . value ( ) ; // _id at the beginning props . unshift ( '_id' ) ; return props ; }
walk the paths, rejecting those that opt-out
walk the paths rejecting those that opt - out