Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Frozen Objects / Realm's #114

Merged
merged 5 commits into from
Nov 23, 2023
Merged

Add support for Frozen Objects / Realm's #114

merged 5 commits into from
Nov 23, 2023

Conversation

leemaguire
Copy link
Contributor

@leemaguire leemaguire commented Nov 13, 2023

  • Add support for Frozen Objects / Realm's
    Usage:
           auto realm = db(std::move(config));
            realm.write([&realm]() {
                realm.add(AllTypesObject());
            });
            auto frozen_realm = realm.freeze();
            MY_ASSERT(frozen_realm.is_frozen();

            auto async = std::async(std::launch::async, [&frozen_realm]() {
                auto thawed = frozen_realm.thaw();
                MY_ASSERT_FALSE(thawed.is_frozen());
                thawed.write([&thawed]() {
                    auto o = AllTypesObject();
                    o._id = 2;
                    thawed.add(std::move(o));
                });
                thawed.write([&thawed]() {
                    auto o = AllTypesObject();
                    o._id = 3;
                    thawed.add(std::move(o));
                });
                MY_ASSERT_FALSE(thawed.refresh());
                MY_ASSERT(thawed.objects<AllTypesObject>().size() == 3);

                MY_ASSERT(frozen_realm.is_frozen());
                MY_ASSERT_FALSE(frozen_realm.refresh());
                MY_ASSERT(frozen_realm.objects<AllTypesObject>().size() == 1);
                return true;
            });
            MY_ASSERT(async.get());
  • Add support for sorting experimental::results / managed<std::vector<T>>
    Usage:
            // For sorting on a single property ascending / descending.
            auto sorted_results_ascending = realm.objects<AllTypesObject>().sort("str_col", true);
            // For sorting on a order of multiple properties ascending / descending.
            auto sorted_results_with_descriptors_ascending = realm.objects<AllTypesObject>().sort({{"str_col", true}, {"_id", true}});

@leemaguire leemaguire self-assigned this Nov 13, 2023
@leemaguire leemaguire force-pushed the lm/frozen branch 4 times, most recently from 138bd6b to 473515e Compare November 19, 2023 09:50
@leemaguire leemaguire marked this pull request as ready for review November 19, 2023 09:51
@leemaguire leemaguire merged commit 54230f1 into main Nov 23, 2023
@leemaguire leemaguire deleted the lm/frozen branch November 23, 2023 02:11
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants