dist/packages/partitioning-adapter/lokidb.partitioning-adapter.js
/**
     * Helper method used internally to save each dirty collection, one at a time.
     *
     * @returns {Promise} a Promise that resolves after the next partition is saved
     */
Helper method used internally to save each dirty collection, one at a time.
@returns {Promise} a Promise that resolves after the next partition is saved
Helper method used internally to save each dirty collection one at a time . @returns { Promise } a Promise that resolves after the next partition is saved
_saveNextPartition() {
        const partition = this._dirtyPartitions.shift();
        const keyname = this._dbname + ((partition === -1) ? "" : ("." + partition));
        if (this._paging && partition !== -1) {
            this._pageIterator = {
                collection: partition,
                docIndex: 0,
                pageIndex: 0
            };
            return this._saveNextPage().then(() => {
                if (this._dirtyPartitions.length !== 0) {
                    return this._saveNextPartition();
                }
                return Promise.resolve();
            });
        }
        const result = this._dbref.serializeDestructured({
            partitioned: true,
            delimited: true,
            partition
        });
        return this._adapter.saveDatabase(keyname, result).then(() => {
            if (this._dirtyPartitions.length !== 0) {
                return this._saveNextPartition();
            }
            return Promise.resolve();
        });
    }
_saveNextPartition ( ) { const partition = this . _dirtyPartitions . shift ( ) ; const keyname = this . _dbname + ( ( partition === - 1 ) ? "" : ( "." + partition ) ) ; if ( this . _paging && partition !== - 1 ) { this . _pageIterator = { collection : partition , docIndex : 0 , pageIndex : 0 } ; return this . _saveNextPage ( ) . then ( ( ) => { if ( this . _dirtyPartitions . length !== 0 ) { return this . _saveNextPartition ( ) ; } return Promise . resolve ( ) ; } ) ; } const result = this . _dbref . serializeDestructured ( { partitioned : true , delimited : true , partition } ) ; return this . _adapter . saveDatabase ( keyname , result ) . then ( ( ) => { if ( this . _dirtyPartitions . length !== 0 ) { return this . _saveNextPartition ( ) ; } return Promise . resolve ( ) ; } ) ; }
Helper method used internally to save each dirty collection, one at a time.
Helper method used internally to save each dirty collection one at a time .
// if we are doing paging and this is collection partition // since saveNextPage recursively calls itself until done, our callback means this whole paged partition is finished // otherwise this is 'non-paged' partioning...