src/nopg.js
function parse_predicate_pgtype(ObjType, document_type, key) {

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

	var schema = (document_type && document_type.$schema) || {};
	debug.assert(schema).is('object');

	if(key[0] === '$') {

		// FIXME: Change this to do direct for everything else but JSON types!

		if(key === '$version') { return 'direct'; }
		if(key === '$created') { return 'direct'; }
		if(key === '$modified') { return 'direct'; }
		if(key === '$name') { return 'direct'; }
		if(key === '$type') { return 'direct'; }
		if(key === '$validator') { return 'direct'; }
		if(key === '$id') { return 'direct'; }
		if(key === '$types_id') { return 'direct'; }
		if(key === '$documents_id') { return 'direct'; }

	} else {

		var type;
		if(schema && schema.properties && schema.properties.hasOwnProperty(key) && schema.properties[key].type) {
			type = schema.properties[key].type;
		}

		if(type === 'number') {
			return 'numeric';
		}

		if(type === 'boolean') {
			return 'boolean';
		}

	}

	return 'text';
}
function parse_predicate_pgtype(ObjType, document_type, key) {

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

	var schema = (document_type && document_type.$schema) || {};
	debug.assert(schema).is('object');

	if(key[0] === '$') {

		// FIXME: Change this to do direct for everything else but JSON types!

		if(key === '$version') { return 'direct'; }
		if(key === '$created') { return 'direct'; }
		if(key === '$modified') { return 'direct'; }
		if(key === '$name') { return 'direct'; }
		if(key === '$type') { return 'direct'; }
		if(key === '$validator') { return 'direct'; }
		if(key === '$id') { return 'direct'; }
		if(key === '$types_id') { return 'direct'; }
		if(key === '$documents_id') { return 'direct'; }

	} else {

		var type;
		if(schema && schema.properties && schema.properties.hasOwnProperty(key) && schema.properties[key].type) {
			type = schema.properties[key].type;
		}

		if(type === 'number') {
			return 'numeric';
		}

		if(type === 'boolean') {
			return 'boolean';
		}

	}

	return 'text';
}
function parse_predicate_pgtype ( ObjType , document_type , key ) { debug . assert ( ObjType ) . is ( 'function' ) ; debug . assert ( document_type ) . ignore ( undefined ) . is ( 'object' ) ; var schema = ( document_type && document_type . $schema ) || { } ; debug . assert ( schema ) . is ( 'object' ) ; if ( key [ 0 ] === '$' ) { // FIXME: Change this to do direct for everything else but JSON types! if ( key === '$version' ) { return 'direct' ; } if ( key === '$created' ) { return 'direct' ; } if ( key === '$modified' ) { return 'direct' ; } if ( key === '$name' ) { return 'direct' ; } if ( key === '$type' ) { return 'direct' ; } if ( key === '$validator' ) { return 'direct' ; } if ( key === '$id' ) { return 'direct' ; } if ( key === '$types_id' ) { return 'direct' ; } if ( key === '$documents_id' ) { return 'direct' ; } } else { var type ; if ( schema && schema . properties && schema . properties . hasOwnProperty ( key ) && schema . properties [ key ] . type ) { type = schema . properties [ key ] . type ; } if ( type === 'number' ) { return 'numeric' ; } if ( type === 'boolean' ) { return 'boolean' ; } } return 'text' ; }
Returns PostgreSQL type for key based on the schema
@FIXME Detect correct types for all keys
Returns PostgreSQL type for key based on the schema