src/query/limit.js
function compile(context, commands) {
    let ii, cmd, limitOptions;

    // log.debug('limit: in-compile cmds:', commands);

    // look for the limit commands within the commands
    for (ii = commands.length - 1; ii >= 0; ii--) {
        cmd = commands[ii];
        if (cmd[0] === LIMIT) {
            // cmdLimit = cmd;
            limitOptions = {
                offset: context.valueOf(cmd[2]),
                limit: context.valueOf(cmd[1])
            };
            commands.splice(ii, 1);
        } else if (limitOptions && cmd[0] === ENTITY_FILTER) {
            // set the options object of the entityFilter command
            if (limitOptions) {
                cmd[3] = { ...cmd[3], ...limitOptions };
            }
            limitOptions = null;
        }
    }

    // if we still have an open limit and no entity filter was found, add one
    if (limitOptions) {
        commands.unshift([ENTITY_FILTER, null, null, limitOptions]);
    }

    return commands;
}
function compile(context, commands) {
    let ii, cmd, limitOptions;

    // log.debug('limit: in-compile cmds:', commands);

    // look for the limit commands within the commands
    for (ii = commands.length - 1; ii >= 0; ii--) {
        cmd = commands[ii];
        if (cmd[0] === LIMIT) {
            // cmdLimit = cmd;
            limitOptions = {
                offset: context.valueOf(cmd[2]),
                limit: context.valueOf(cmd[1])
            };
            commands.splice(ii, 1);
        } else if (limitOptions && cmd[0] === ENTITY_FILTER) {
            // set the options object of the entityFilter command
            if (limitOptions) {
                cmd[3] = { ...cmd[3], ...limitOptions };
            }
            limitOptions = null;
        }
    }

    // if we still have an open limit and no entity filter was found, add one
    if (limitOptions) {
        commands.unshift([ENTITY_FILTER, null, null, limitOptions]);
    }

    return commands;
}
function compile ( context , commands ) { let ii , cmd , limitOptions ; // log.debug('limit: in-compile cmds:', commands); // look for the limit commands within the commands for ( ii = commands . length - 1 ; ii >= 0 ; ii -- ) { cmd = commands [ ii ] ; if ( cmd [ 0 ] === LIMIT ) { // cmdLimit = cmd; limitOptions = { offset : context . valueOf ( cmd [ 2 ] ) , limit : context . valueOf ( cmd [ 1 ] ) } ; commands . splice ( ii , 1 ) ; } else if ( limitOptions && cmd [ 0 ] === ENTITY_FILTER ) { // set the options object of the entityFilter command if ( limitOptions ) { cmd [ 3 ] = { ... cmd [ 3 ] , ... limitOptions } ; } limitOptions = null ; } } // if we still have an open limit and no entity filter was found, add one if ( limitOptions ) { commands . unshift ( [ ENTITY_FILTER , null , null , limitOptions ] ) ; } return commands ; }
Compilation involves altering the previous entityfilter so that it receives the
limit arguments
Compilation involves altering the previous entityfilter so that it receives the limit arguments