src/nopg.js
function parse_search_opts(opts, traits) {

	if(opts === undefined) {
		return;
	}

	if(is.array(opts)) {
		if( (opts.length >= 1) && is.obj(opts[0]) ) {
			return [ ((traits.match === 'any') ? 'OR' : 'AND') ].concat(opts);
		}
		return opts;
	}

	if(opts instanceof NoPg.Type) {
		return [ "AND", { "$id": opts.$id } ];
	}

	if(is.obj(opts)) {
		return [ ((traits.match === 'any') ? 'OR' : 'AND') , opts];
	}

	return [ "AND", {"$name": ''+opts} ];
}
function parse_search_opts(opts, traits) {

	if(opts === undefined) {
		return;
	}

	if(is.array(opts)) {
		if( (opts.length >= 1) && is.obj(opts[0]) ) {
			return [ ((traits.match === 'any') ? 'OR' : 'AND') ].concat(opts);
		}
		return opts;
	}

	if(opts instanceof NoPg.Type) {
		return [ "AND", { "$id": opts.$id } ];
	}

	if(is.obj(opts)) {
		return [ ((traits.match === 'any') ? 'OR' : 'AND') , opts];
	}

	return [ "AND", {"$name": ''+opts} ];
}
function parse_search_opts ( opts , traits ) { if ( opts === undefined ) { return ; } if ( is . array ( opts ) ) { if ( ( opts . length >= 1 ) && is . obj ( opts [ 0 ] ) ) { return [ ( ( traits . match === 'any' ) ? 'OR' : 'AND' ) ] . concat ( opts ) ; } return opts ; } if ( opts instanceof NoPg . Type ) { return [ "AND" , { "$id" : opts . $id } ] ; } if ( is . obj ( opts ) ) { return [ ( ( traits . match === 'any' ) ? 'OR' : 'AND' ) , opts ] ; } return [ "AND" , { "$name" : '' + opts } ] ; }
Parse opts object
Parse opts object