lib/adapter.js
function (connectionName, table, options, cb) {
            if (LOG_DEBUG) {
                console.log('BEGIN find');
            }
            // Grab Connection Schema
            var schema = {};
            var connectionObject = connections[connectionName];
            var collection = connectionObject.collections[table];
            
            Object.keys(connectionObject.collections).forEach(function (coll) {
                schema[coll] = connectionObject.collections[coll].schema;
            });

            // Build 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 _query;
            
            var limit = options.limit || null;
            var skip = options.skip || null;
            delete options.skip;
            delete options.limit;
            
            
            // Build a query for the specific query strategy
            delete options.select;
            try {
                _query = sequel.find(table, options);
            } catch (e) {
                return cb(e);
            }
            
            var findQuery = _query.query[0];
            findQuery = findQuery.replace( /\$/g, ':');
            findQuery = findQuery.replace(" AS ", " ");
            
            if (limit && skip) {
                findQuery = 'SELECT * FROM ( select a.*, ROWNUM LINE_NUMBER from (' + findQuery + ') a  where ROWNUM <= '+(skip + limit)+' ) where LINE_NUMBER  > '+skip;
            }
            else if (limit) {
                findQuery = 'SELECT * FROM ( select a.*, ROWNUM LINE_NUMBER from (' + findQuery + ') a  where ROWNUM <= '+limit+' )';
            }
            else if (skip) {
                findQuery = 'SELECT * FROM ( select a.*, ROWNUM LINE_NUMBER from (' + findQuery + ') a  where ROWNUM > ' + skip;
            }
            
            

            // Run Query
            connectionObject.pool.getConnection(
                    function (err, connection)
                    {
                        if (err) {
                            console.log(err);
                            doRelease(connection);
                            return cb(handleQueryError(err, 'find'));
                        }
                        if (LOG_QUERIES) {
                            console.log('Executing query: ' + findQuery);
                        }
                        connection.execute(findQuery, _query.values[0], {outFormat: oracledb.OBJECT}, function __FIND__(err, result) {
                            if (err) {
                                /* Release the connection back to the connection pool */
                                doRelease(connection);
                                return cb(handleQueryError(err, 'find'));
                            }

                            // Cast special values
                            var values = [];

                            result.rows.forEach(function (row) {
                                
                                values.push(processor.cast(table, _.omit(row, 'LINE_NUMBER')));
                            });


                            /* Release the connection back to the connection pool */
                            doRelease(connection);

                            return cb(null, values);

                        });
                    });


            if (LOG_DEBUG) {
                console.log('END find');
            }
        }
function (connectionName, table, options, cb) {
            if (LOG_DEBUG) {
                console.log('BEGIN find');
            }
            // Grab Connection Schema
            var schema = {};
            var connectionObject = connections[connectionName];
            var collection = connectionObject.collections[table];
            
            Object.keys(connectionObject.collections).forEach(function (coll) {
                schema[coll] = connectionObject.collections[coll].schema;
            });

            // Build 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 _query;
            
            var limit = options.limit || null;
            var skip = options.skip || null;
            delete options.skip;
            delete options.limit;
            
            
            // Build a query for the specific query strategy
            delete options.select;
            try {
                _query = sequel.find(table, options);
            } catch (e) {
                return cb(e);
            }
            
            var findQuery = _query.query[0];
            findQuery = findQuery.replace( /\$/g, ':');
            findQuery = findQuery.replace(" AS ", " ");
            
            if (limit && skip) {
                findQuery = 'SELECT * FROM ( select a.*, ROWNUM LINE_NUMBER from (' + findQuery + ') a  where ROWNUM <= '+(skip + limit)+' ) where LINE_NUMBER  > '+skip;
            }
            else if (limit) {
                findQuery = 'SELECT * FROM ( select a.*, ROWNUM LINE_NUMBER from (' + findQuery + ') a  where ROWNUM <= '+limit+' )';
            }
            else if (skip) {
                findQuery = 'SELECT * FROM ( select a.*, ROWNUM LINE_NUMBER from (' + findQuery + ') a  where ROWNUM > ' + skip;
            }
            
            

            // Run Query
            connectionObject.pool.getConnection(
                    function (err, connection)
                    {
                        if (err) {
                            console.log(err);
                            doRelease(connection);
                            return cb(handleQueryError(err, 'find'));
                        }
                        if (LOG_QUERIES) {
                            console.log('Executing query: ' + findQuery);
                        }
                        connection.execute(findQuery, _query.values[0], {outFormat: oracledb.OBJECT}, function __FIND__(err, result) {
                            if (err) {
                                /* Release the connection back to the connection pool */
                                doRelease(connection);
                                return cb(handleQueryError(err, 'find'));
                            }

                            // Cast special values
                            var values = [];

                            result.rows.forEach(function (row) {
                                
                                values.push(processor.cast(table, _.omit(row, 'LINE_NUMBER')));
                            });


                            /* Release the connection back to the connection pool */
                            doRelease(connection);

                            return cb(null, values);

                        });
                    });


            if (LOG_DEBUG) {
                console.log('END find');
            }
        }
Select Query Logic - OK