question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Initial data for models

See original GitHub issue

Is there a way to populate the initial data:

  • the first time a boxStore is created
  • in a way that’s blocking for queries and puts
  • runs in the background

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
jpmcostacommented, Nov 23, 2017

As I see things, it would make sense for ObjectBox to call some initializer (if set) to make sure the database is populated with all necessary data before the application starts interacting with it, when its file is first created.

I feel that relying on SharedPreferences to initialize data, or checking if the data is populated on every run is not ideal. The Future workflow makes sense, but it probably makes the interaction with the library more complicated than it needs to be, and it might be blocking even when there are no queries or puts (issues with dependency injection maybe).

It would be nice if the heavy-lifting was done by the library, behind the scenes. However, I don’t know how difficult would it be to implement this. It also might come with some side-effects for cases when it’s not used, but that comes with most features.

In my case, I would make use of such feature, but it’s not vital. Even on cases where the sequence of events is not ideal there shouldn’t be any major issues.

0reactions
greenrobot-teamcommented, Sep 8, 2020

Way back in 2018 1.4.4 added BoxStoreBuilder.initialDbFile​(initialDbFile). Closing this then.

Feel free to re-open or create a new issue if your problem was not solved.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to provide initial data for models - Django documentation
How to provide initial data for models¶. It's sometimes useful to prepopulate your database with hard-coded data when you're first setting up an...
Read more >
How to provide initial data in Django Models?
You can load data by calling manage.py loaddata <fixturename>, where <fixturename> is the name of the fixture file you've created. Each time you ......
Read more >
Providing initial data for models - Django - Stack Overflow
1 Answer 1 ... I found the way to do it. First will we create a JSON file using below line. Note -...
Read more >
Django model initial data set up - Web Forefront
The simplest approach to set up initial data is to hard-code the set of pre-defined data records and make it part of the...
Read more >
Set up and Load Initial Data in Django - DEV Community ‍ ‍
Django provides two ways of setting up and loading this initial data to our database. Using Fixtures; Using Migrations. For the purposes of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found