Skip to content

Bucket

Bucket

Represents a bucket in ReductStore

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.removeEntry(entry) ⇒ Promise.<void>

Remove an entry

Kind: instance method of Bucket

Param Type Description
entry string name of the entry

bucket.beginWrite(entry, options) ⇒

Start writing a record into an entry

Kind: instance method of Bucket
Returns: Promise

Param Type Description
entry name of the entry
options BigInt | WriteOptions timestamp in microseconds for the record or options. It is current time if undefined.

Example

const record = await bucket.beginWrite("entry", {
 ts: 12345667n
 labels: {label1: "value1", label2: "value2"}
 contentType: "text/plain"
);
await record.write("Hello!);

bucket.beginRead(entry, ts, head) ⇒

Start reading a record from an entry

Kind: instance method of Bucket
Returns: Promise

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

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

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
options number | QueryOptions if number it is TTL of query on the server side, otherwise it is options for query

Example

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

bucket.beginWriteBatch(entry)

Create a new batch for writing records to the database.

Kind: instance method of Bucket

Param
entry