lib/sql.js
// Cast waterline types into SQL data types

Cast waterline types into SQL data types
Cast waterline types into SQL data types
function sqlTypeCast(type, attrName) {
    type = type && type.toLowerCase();
    switch (type) {
        case 'string':
            return 'VARCHAR2(255)';
        case 'text':
        case 'array':
        case 'json':
            return 'VARCHAR2(255)';
        case 'boolean':
            return 'NUMBER(1) CHECK("' + attrName + '" IN (0,1))';
        case 'int':
        case 'integer':
            return 'NUMBER';
        case 'float':
        case 'double':
            return 'FLOAT';
        case 'date':
            return 'DATE';
        case 'datetime':
            return 'TIMESTAMP';
        case 'binary':
            return 'BLOB';
        default:
            console.error("Unregistered type given: " + type);
            return "TEXT";
    }
}
function sqlTypeCast ( type , attrName ) { type = type && type . toLowerCase ( ) ; switch ( type ) { case 'string' : return 'VARCHAR2(255)' ; case 'text' : case 'array' : case 'json' : return 'VARCHAR2(255)' ; case 'boolean' : return 'NUMBER(1) CHECK("' + attrName + '" IN (0,1))' ; case 'int' : case 'integer' : return 'NUMBER' ; case 'float' : case 'double' : return 'FLOAT' ; case 'date' : return 'DATE' ; case 'datetime' : return 'TIMESTAMP' ; case 'binary' : return 'BLOB' ; default : console . error ( "Unregistered type given: " + type ) ; return "TEXT" ; } }
Cast waterline types into SQL data types
Cast waterline types into SQL data types