Initial data for models
See original GitHub issueIs 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:
- Created 6 years ago
- Reactions:1
- Comments:5 (3 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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. TheFuture
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.
Way back in 2018
1.4.4
addedBoxStoreBuilder.initialDbFile(initialDbFile)
. Closing this then.Feel free to re-open or create a new issue if your problem was not solved.