Skip to content

Bucket

Bucket

Represents a bucket in Reduct Storage

Kind: global class
See: {Client}

new Bucket(name, httpClient)

Create a bucket. Use Client.creatBucket or Client.getBucket instead it

Param
name
httpClient

bucket.getSettings() ⇒ Promise.<BucketSettings>

Get bucket settings

Kind: instance method of Bucket

bucket.setSettings(settings)

Set bucket settings

Kind: instance method of Bucket

Param Type Description
settings BucketSettings new settings (you can set a part of settings)

bucket.getInfo() ⇒ Promise.<BucketInfo>

Get information about a bucket

Kind: instance method of Bucket

bucket.getEntryList() ⇒ Promise.<EntryInfo>

Get entry list

Kind: instance method of Bucket

bucket.remove() ⇒ Promise.<void>

Remove bucket

Kind: instance method of Bucket

bucket.write(entry, data, ts)

Write a record into an entry

Kind: instance method of Bucket

Param Type Description
entry name of the entry
data string | Buffer data as string
ts BigInt timestamp in microseconds for the record. It is current time if undefined.

bucket.writeStream(entry, stream, content_length, ts)

Write a record from a stream

Kind: instance method of Bucket

Param Type Description
entry name of the entry
stream stream to write
content_length content length in size. The storage engine should know it in advance
ts BigInt timestamp in microseconds for the record. It is current time if undefined.

bucket.read(entry, ts)

Read a record from an entry

Kind: instance method of Bucket

Param Type Description
entry name of the entry
ts BigInt timestamp of record in microseconds. Get the latest one, if undefined

bucket.readStream(entry, ts)

Read a record from an entry as a stream

Kind: instance method of Bucket

Param Type Description
entry name of the entry
ts BigInt timestamp of record in microseconds. Get the latest one, if undefined

bucket.list(entry, start, stop)

Deprecated

List records for a time period

Kind: instance method of Bucket

Param Type Description
entry string name of the entry
start BigInt start point of the time period
stop BigInt stop point of the time period

bucket.query(entry, entry, start, stop, ttl)

Query records for a time interval as generator

Kind: instance method of Bucket

Param Type Description
entry entry name
entry string name of the entry
start BigInt start point of the time period
stop BigInt stop point of the time period
ttl number TTL of query on the server side

Example

for await (const record in bucket.query("entry-1", start, stop)) {
  console.log(record.ts, record.size);
  const content = await record.read();
  // or use pipe
  const fileStream = fs.createWriteStream(`ts_${record.size}.txt`);
  record.pipe(fileStream);
}