Class: Sbucket

Sbucket(dbPath, optionsopt)

Capped LevelDB database within a Btable

Constructor

new Sbucket(dbPath, optionsopt)

Parameters:
Name Type Attributes Description
dbPath String The path to database on disk
options Object <optional>
Options to pass through to leveldown#open
Properties
Name Type Attributes Default Description
maxOpenFiles Number <optional>
1000
compression Boolean <optional>
false
cacheSize Number <optional>
8388608
createIfMissing Boolean <optional>
true
errorIfExists Boolean <optional>
false
writeBufferSize Number <optional>
4194304
blockSize Number <optional>
4096
blockRestartInterval Number <optional>
16
Source:

Methods

close(callback)

Closes the underlying database
Parameters:
Name Type Description
callback Sbucket~closeCallback
Source:
Fires:

createReadStream(key) → {ReadableFileStream}

Returns a readable stream of the file at the given key
Parameters:
Name Type Description
key String The key for the file to read
Source:
Returns:
Type
ReadableFileStream

createWriteStream(key) → {WritableFileStream}

Returns a writable stream for a file at the given key
Parameters:
Name Type Description
key String The key for the file to read
Source:
Returns:
Type
WritableFileStream

exists(key, callback)

Determines if the file is already stored in the db
Parameters:
Name Type Description
key String The key for the file stored
callback Sbucket~existsCallback
Source:

flush(callback)

Trigger a compaction for the S-bucket
Parameters:
Name Type Description
callback Sbucket~flushCallback
Source:

list(callback)

Get a list of file keys in the bucket and their approximate size
Parameters:
Name Type Description
callback Sbucket~listCallback
Source:

open(callback)

Opens the underlying database
Parameters:
Name Type Description
callback Sbucket~openCallback
Source:
Fires:

readFile(key, callback)

Reads the file at the given key into a buffer
Parameters:
Name Type Description
key String The key for the file to read
callback Sbucket~readFileCallback
Source:

stat(callback)

Get stats for this bucket
Parameters:
Name Type Description
callback Sbucket~statCallback
Source:
Deletes the file chunks from the database
Parameters:
Name Type Description
key String The key for the file stored
callback Sbucket~unlinkCallback
Source:

writeFile(key, buffer, callback)

Writes the buffer to the given key
Parameters:
Name Type Description
key String The key for the file to write
buffer Buffer The data to write to the given key
callback Sbucket~writeFileCallback
Source:

Type Definitions

closeCallback(erroropt)

Parameters:
Name Type Attributes Description
error Error <optional>
Source:

existsCallback(erroropt, fileDoesExist)

Parameters:
Name Type Attributes Description
error Error <optional>
fileDoesExist Boolean
Source:

flushCallback(error)

Parameters:
Name Type Description
error Error | null
Source:

listCallback(erroropt, results)

Parameters:
Name Type Attributes Description
error Error <optional>
results Array.<Object>
Properties
Name Type Description
baseKey String
approximateSize Number
Source:

openCallback(erroropt)

Parameters:
Name Type Attributes Description
error Error <optional>
Source:

readFileCallback(erroropt, fileBuffer)

Parameters:
Name Type Attributes Description
error Error <optional>
fileBuffer Buffer
Source:

statCallback(erroropt, bucketStats)

Parameters:
Name Type Attributes Description
error Error <optional>
bucketStats Object
Properties
Name Type Description
size Number The used space in bytes
free Number The free space left in bytes
Source:

unlinkCallback(erroropt)

Parameters:
Name Type Attributes Description
error Error <optional>
Source:

writeFileCallback(erroropt)

Parameters:
Name Type Attributes Description
error Error <optional>
Source:

Events

close

Triggered when the underlying database closes
Source:

idle

Triggered when there are no more pending operations
Source:

locked

Triggered when the bucket is locked for flushing
Source:

open

Triggered when the underlying database opens
Source:

unlocked

Triggered when the bucket is unlocked
Source: