private function createCommandDocument()
    {
        $cmd = ['find' => $this->collectionName, 'filter' => (object) $this->filter];

        $options = $this->createQueryOptions();

        if (empty($options)) {
            return $cmd;
        }

        // maxAwaitTimeMS is a Query level option so should not be considered here
        unset($options['maxAwaitTimeMS']);

        $modifierFallback = [
            ['allowPartialResults', 'partial'],
            ['comment', '$comment'],
            ['hint', '$hint'],
            ['maxScan', '$maxScan'],
            ['max', '$max'],
            ['maxTimeMS', '$maxTimeMS'],
            ['min', '$min'],
            ['returnKey', '$returnKey'],
            ['showRecordId', '$showDiskLoc'],
            ['sort', '$orderby'],
            ['snapshot', '$snapshot'],
        ];

        foreach ($modifierFallback as $modifier) {
            if ( ! isset($options[$modifier[0]]) && isset($options['modifiers'][$modifier[1]])) {
                $options[$modifier[0]] = $options['modifiers'][$modifier[1]];
            }
        }
        unset($options['modifiers']);

        return $cmd + $options;
    }
private function createCommandDocument()
    {
        $cmd = ['find' => $this->collectionName, 'filter' => (object) $this->filter];

        $options = $this->createQueryOptions();

        if (empty($options)) {
            return $cmd;
        }

        // maxAwaitTimeMS is a Query level option so should not be considered here
        unset($options['maxAwaitTimeMS']);

        $modifierFallback = [
            ['allowPartialResults', 'partial'],
            ['comment', '$comment'],
            ['hint', '$hint'],
            ['maxScan', '$maxScan'],
            ['max', '$max'],
            ['maxTimeMS', '$maxTimeMS'],
            ['min', '$min'],
            ['returnKey', '$returnKey'],
            ['showRecordId', '$showDiskLoc'],
            ['sort', '$orderby'],
            ['snapshot', '$snapshot'],
        ];

        foreach ($modifierFallback as $modifier) {
            if ( ! isset($options[$modifier[0]]) && isset($options['modifiers'][$modifier[1]])) {
                $options[$modifier[0]] = $options['modifiers'][$modifier[1]];
            }
        }
        unset($options['modifiers']);

        return $cmd + $options;
    }
private function createCommandDocument ( ) { $ cmd = [ 'find' => $ this -> collectionName , 'filter' => ( object ) $ this -> filter ] ; $ options = $ this -> createQueryOptions ( ) ; if ( empty ( $ options ) ) { return $ cmd ; } // maxAwaitTimeMS is a Query level option so should not be considered here unset ( $ options [ 'maxAwaitTimeMS' ] ) ; $ modifierFallback = [ [ 'allowPartialResults' , 'partial' ] , [ 'comment' , '$comment' ] , [ 'hint' , '$hint' ] , [ 'maxScan' , '$maxScan' ] , [ 'max' , '$max' ] , [ 'maxTimeMS' , '$maxTimeMS' ] , [ 'min' , '$min' ] , [ 'returnKey' , '$returnKey' ] , [ 'showRecordId' , '$showDiskLoc' ] , [ 'sort' , '$orderby' ] , [ 'snapshot' , '$snapshot' ] , ] ; foreach ( $ modifierFallback as $ modifier ) { if ( ! isset ( $ options [ $ modifier [ 0 ] ] ) && isset ( $ options [ 'modifiers' ] [ $ modifier [ 1 ] ] ) ) { $ options [ $ modifier [ 0 ] ] = $ options [ 'modifiers' ] [ $ modifier [ 1 ] ] ; } } unset ( $ options [ 'modifiers' ] ) ; return $ cmd + $ options ; }
Construct a command document for Find
Construct a command document for Find