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 data initialization function #441

Merged
merged 7 commits into from
Apr 12, 2022

Conversation

nirinchev
Copy link
Member

@nirinchev nirinchev commented Mar 29, 2022

Depends on #455 and #456, so will rebase on master once those go in.

This adds a Configuration property that allows developers to specify a function that imports an initial set of data the first time the Realm is opened.

final config = Configuration([Person.schema]);
config.initialDataCallback = (realm) {
  // realm is already in a write transaction
  realm.add(Person('peter'));
  realm.add(Person('george'));
};

Fixes #298

@cla-bot cla-bot bot added the cla: yes label Mar 29, 2022
src/realm_dart_realm.h Outdated Show resolved Hide resolved
@coveralls
Copy link

coveralls commented Mar 29, 2022

Pull Request Test Coverage Report for Build 2115316376

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 91.841%

Totals Coverage Status
Change from base Build 2115293703: 0.0%
Covered Lines: 394
Relevant Lines: 429

💛 - Coveralls

@nirinchev nirinchev self-assigned this Mar 30, 2022
@nirinchev nirinchev marked this pull request as ready for review March 30, 2022 13:09
@nirinchev nirinchev requested a review from blagoev March 30, 2022 13:10
lib/src/native/realm_core.dart Outdated Show resolved Hide resolved
lib/src/native/realm_core.dart Outdated Show resolved Hide resolved
src/realm_dart.cpp Outdated Show resolved Hide resolved
lib/src/configuration.dart Outdated Show resolved Hide resolved
src/realm_dart.cpp Outdated Show resolved Hide resolved
lib/src/native/realm_core.dart Outdated Show resolved Hide resolved
lib/src/native/realm_core.dart Outdated Show resolved Hide resolved
lib/src/native/realm_core.dart Outdated Show resolved Hide resolved
lib/src/native/realm_core.dart Outdated Show resolved Hide resolved
lib/src/configuration.dart Outdated Show resolved Hide resolved
@nirinchev nirinchev force-pushed the ni/initial-data-callback branch 4 times, most recently from 1d93c03 to 8c6e24c Compare April 8, 2022 13:44
@nirinchev nirinchev changed the base branch from master to gc-handles April 8, 2022 13:46
@nirinchev nirinchev changed the base branch from gc-handles to ni/dumb-config April 8, 2022 22:45
@nirinchev nirinchev changed the base branch from ni/dumb-config to ni/config-gchandles-2 April 8, 2022 22:48
lib/src/configuration.dart Outdated Show resolved Hide resolved
lib/src/native/realm_core.dart Outdated Show resolved Hide resolved
@blagoev
Copy link
Contributor

blagoev commented Apr 11, 2022

my PR review comments are all over the place. Sorry about that. Don't know how it happens

@nirinchev nirinchev force-pushed the ni/initial-data-callback branch 2 times, most recently from 972ea0a to b8e5c23 Compare April 11, 2022 20:28
@nirinchev nirinchev changed the base branch from ni/config-gchandles-2 to master April 11, 2022 20:29
@nirinchev
Copy link
Member Author

@blagoev @nielsenko @desistefanova this is now rebased on master and cleaned up, so should be ready for another look. It changed significantly since I integrated the GCHandle approach, so it's likely worth it reviewing the core functionality from scratch.

Co-authored-by: Desislava Stefanova <95419820+desistefanova@users.noreply.github.com>
lib/src/native/realm_core.dart Outdated Show resolved Hide resolved
lib/src/native/realm_core.dart Outdated Show resolved Hide resolved
@blagoev blagoev merged commit 7126346 into master Apr 12, 2022
@blagoev blagoev deleted the ni/initial-data-callback branch April 12, 2022 05:22
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support data init function
5 participants