DEV Community

Cover image for ReductStore Client SDK for C++ v1.3.0 with Labels Support
Alexey Timin for ReductStore

Posted on • Originally published at reduct.store

ReductStore Client SDK for C++ v1.3.0 with Labels Support

We are excited to announce the release of ReductStore Client SDK for C++ v1.3.0! This release includes support for the ReductStore API v1.3.0 with labels and content type.

Labels

Since ReductStore v1.3.0, you can attach labels to data when writing and querying. Labels are key-value pairs that can be used to classify and categorize data. For example, you might use labels to store metadata about a record, such as its md5 sum or class.

auto [bucket, err] =  client->CreateBucket(kBucketName);

IBucket::Time ts = IBucket::Time() + std::chrono::microseconds(123109210);
std::string blob = "some blob of data";
bucket->Write("entry",
    IBucket::WriteOptions{
        .timestamp = ts,
        .labels = IBucket::LableMap({"label1", "value3"}),
    },
    [&blob](auto rec) { rec->WriteAll(blob); 
});

Enter fullscreen mode Exit fullscreen mode

This labels can be used to filter the results of a query:

auto err = bucket->Query("entry", ts, ts + us(3), 
    IBucket::QueryOptions{.include = IBucket::LabelMap({"label1", "value1"})},
    [&all_data](auto record) {
        std::cout << record->ReadAll() << std::endl;
    }
);

Enter fullscreen mode Exit fullscreen mode

Content Type

You can now specify the content type of the data you are writing to the ReductStore database. This could be useful for example when you are writing a file to the database and want to store the file extension as the content type or keep information about the image format.

bucket->Write("entry", I
    Bucket::WriteOptions{
        .content_type = "image/png",
    },
    [&blob](auto rec) { rec->WriteAll(image_as_blob); }
 );
Enter fullscreen mode Exit fullscreen mode

Read more about labels and content type in the ReductStore documentation.

I hope you find this release useful. If you have any questions or feedback, don't hesitate to reach out in Discord or by opening a discussion on GitHub.

Thanks for using ReductStore!

Oldest comments (0)