src/nopg.js
function _parse_select_order(ObjType, document_type, order, q, traits) {

	debug.assert(ObjType).is('function');
	debug.assert(document_type).ignore(undefined).is('object');
	debug.assert(order).is('array');

	return ARRAY(order).map(function(o) {
		var key, type, rest;
		if(is.array(o)) {
			key = parse_operator_name(o[0]);
			type = parse_operator_type(o[0], 'text');
			rest = o.slice(1);
		} else {
			key = parse_operator_name(o);
			type = parse_operator_type(o, 'text');
			rest = [];
		}

		if(key === 'BIND') {
			return _parse_function_predicate(ObjType, q, undefined, rest, type, traits);
		}

		//debug.log('key = ', key);
		var parsed_key = _parse_predicate_key(ObjType, {'traits': traits, 'epoch':true}, key);
		//debug.log('parsed_key = ', parsed_key);
		var pgcast = parse_predicate_pgcast(ObjType, document_type, key);
		//debug.log('pgcast = ', pgcast);

		return new Predicate( [pgcast(parsed_key.getString())].concat(rest).join(' '), parsed_key.getParams(), parsed_key.getMetaObject() );
	}).valueOf();
}
function _parse_select_order(ObjType, document_type, order, q, traits) {

	debug.assert(ObjType).is('function');
	debug.assert(document_type).ignore(undefined).is('object');
	debug.assert(order).is('array');

	return ARRAY(order).map(function(o) {
		var key, type, rest;
		if(is.array(o)) {
			key = parse_operator_name(o[0]);
			type = parse_operator_type(o[0], 'text');
			rest = o.slice(1);
		} else {
			key = parse_operator_name(o);
			type = parse_operator_type(o, 'text');
			rest = [];
		}

		if(key === 'BIND') {
			return _parse_function_predicate(ObjType, q, undefined, rest, type, traits);
		}

		//debug.log('key = ', key);
		var parsed_key = _parse_predicate_key(ObjType, {'traits': traits, 'epoch':true}, key);
		//debug.log('parsed_key = ', parsed_key);
		var pgcast = parse_predicate_pgcast(ObjType, document_type, key);
		//debug.log('pgcast = ', pgcast);

		return new Predicate( [pgcast(parsed_key.getString())].concat(rest).join(' '), parsed_key.getParams(), parsed_key.getMetaObject() );
	}).valueOf();
}
function _parse_select_order ( ObjType , document_type , order , q , traits ) { debug . assert ( ObjType ) . is ( 'function' ) ; debug . assert ( document_type ) . ignore ( undefined ) . is ( 'object' ) ; debug . assert ( order ) . is ( 'array' ) ; return ARRAY ( order ) . map ( function ( o ) { var key , type , rest ; if ( is . array ( o ) ) { key = parse_operator_name ( o [ 0 ] ) ; type = parse_operator_type ( o [ 0 ] , 'text' ) ; rest = o . slice ( 1 ) ; } else { key = parse_operator_name ( o ) ; type = parse_operator_type ( o , 'text' ) ; rest = [ ] ; } if ( key === 'BIND' ) { return _parse_function_predicate ( ObjType , q , undefined , rest , type , traits ) ; } //debug.log('key = ', key); var parsed_key = _parse_predicate_key ( ObjType , { 'traits' : traits , 'epoch' : true } , key ) ; //debug.log('parsed_key = ', parsed_key); var pgcast = parse_predicate_pgcast ( ObjType , document_type , key ) ; //debug.log('pgcast = ', pgcast); return new Predicate ( [ pgcast ( parsed_key . getString ( ) ) ] . concat ( rest ) . join ( ' ' ) , parsed_key . getParams ( ) , parsed_key . getMetaObject ( ) ) ; } ) . valueOf ( ) ; }
Generate ORDER BY using `traits.order`
Generate ORDER BY using traits . order