Note
. It is persisted (saved) in the database and contains all data that is part of a note, like an id, note text and the creation date.@Entity
and @Id
.MyObjectBox.java
, and some other classes used by ObjectBox internally.MyObjectBox.kt
, and some other classes used by ObjectBox internally.pub run build_runner build
after making any changes to the entity classes. ObjectBox generator will look for all @Entity
annotations in your lib
folder and create a single database definition lib/objectbox-model.json
and supporting code in lib/objectbox.g.dart
. objectbox-model.json
into your source control (e.g. git) and add objectbox.g.dart
to the ignore list (e.g. .gitignore), otherwise, the build_runner will complain about it being changed each time you pull a change.lib
and test
folders separately and create a separate database in each if it finds annotated entities there. This is useful if you need a separate test database. If you're just writing tests for your own code, you won't have any annotations in the test
folder so no DB model will be created there.Box<Note>
provides database operations for Note
objects.ObjectBox
is the name of a helper class to set up and keep a reference to BoxStore
.ObjectBox
is the name of a helper class to set up and keep a reference to BoxStore
.addNote()
is called. There, a new Note
object is created and put into the database using the Box
reference:Note
object), is assigned by ObjectBox during put()
.Box
provides remove()
to achieve this:Query
instance is built once:put()
again with the changed object: