nl_tokens: Add a new row to the table - OK
pl_tokens: function ( connectionName , table , data , cb ) { if ( LOG_DEBUG ) { console . log ( "BEGIN create" ) ; } var connectionObject = connections [ connectionName ] ; var collection = connectionObject . collections [ table ] ; var schemaName = collection . meta && collection . meta . schemaName ? utils . escapeName ( collection . meta . schemaName ) + '.' : '' ; var tableName = schemaName + utils . escapeName ( table ) ; // Build up a SQL Query var schema = connectionObject . schema ; var processor = new Processor ( schema ) ; // Mixin WL Next connection overrides to sqlOptions var overrides = connectionOverrides [ connectionName ] || { } ; var options = _ . cloneDeep ( sqlOptions ) ; if ( hop ( overrides , 'wlNext' ) ) { options . wlNext = overrides . wlNext ; } var sequel = new Sequel ( schema , options ) ; var incrementSequences = [ ] ; var query ; Object . keys ( schema [ table ] . attributes ) . forEach ( function ( column ) { if ( schema [ table ] . attributes [ column ] . type === 'datetime' ) { data [ column ] = new Date ( data [ column ] ) ; //'to_date('+moment(data[column]).format('YYYY/MM/DD HH:mm:ss')+','+formatDate+')';//moment(data[column]).format('YYYY/MM/DD HH:mm:ss'); } } ) ; // Build a query for the specific query strategy try { query = sequel . create ( table , data ) ; } catch ( e ) { return cb ( e ) ; } //ToDo: Now id ALWAYS should be autoIncrement and you cannot set it manually.  query . query = query . query . replace ( 'RETURNING *' , '' ) ; query . query = query . query . replace ( / \$ / g , ':' ) ; // Run Query connectionObject . pool . getConnection ( function ( err , connection ) { if ( <mask> ) { handleQueryError ( err , 'create' ) ; return ; } if ( LOG_QUERIES ) { console . log ( 'Executing query: ' + query . query ) ; } connection . execute ( query . query , _ . values ( data ) , { /*outFormat: oracledb.OBJECT, */ autoCommit : false } , function __CREATE__ ( err , result ) { if ( err ) { // Release the connection back to the connection pool doRelease ( connection ) ; return cb ( handleQueryError ( err , 'create' ) ) ; } var selectQuery = 'select * from "' + table + '" order by "' + _getPK ( connectionName , table ) + '" desc' ; connection . execute ( selectQuery , [ ] , { maxRows : 1 , outFormat : oracledb . OBJECT } , function __CREATE_SELECT__ ( err , result ) { if ( err ) { // Release the connection back to the connection pool doRelease ( connection ) ; return cb ( handleQueryError ( err , 'create_select' ) ) ; } // Cast special values var values = processor . cast ( table , result . rows [ 0 ] ) ; connection . commit ( function ( err ) { // Release the connection back to the connection pool doRelease ( connection ) ; if ( err ) { return cb ( handleQueryError ( err , 'create_commit' ) ) ; } cb ( null , values ) ; } ) ; } ) ; } ) ; } ) ; }