Closed normidar closed 3 months ago
so I can't create an @Entity annotation for ObjectBox on my application.
I'm not sure what exactly is required. But from a clean architecture perspective, I would strongly suggest to look into using a separate model for the database(s) and map to whatever model is required for the application or the network layer (JSON). This will avoid any migration issues in the future.
Anyhow, there are no plans to allow storing data outside of an @Entity
class, as that is the whole point of this library.
In a future release, it might be possible to store a map or list of objects. Similar to the flex properties feature of the Java library: https://docs.objectbox.io/advanced/custom-types#flex-properties
(Internal issue objectbox/objectbox-dart#5
)
I haven't used ObjectBox before, but I'm looking for a way to store data like this: .put({'name': 'abc', 'age': 19})
I prefer not to use entities to create models, as I'm using a wrapper to manage multiple databases, including Firebase, SQLite, Hive, and others.
I haven't used ObjectBox before, but I'm looking for a way to store data like this:
.put({'name': 'abc', 'age': 19})
This is not possible, as I said the whole point of ObjectBox is that it works with Dart classes. With that said, it is possible to create an @Entity
class that just contains a String
property:
@Entity()
class Wrapper {
@Id()
int id;
String value; // Store the JSON here
Wrapper({this.id = 0, required this.value});
}
But then there are no benefits like queries or indexes.
Okay, thanks. I will close the issue.
Is there an existing issue?
Use case
I am using another database and plan to use ObjectBox.
I have a wrapper to access all my databases, so I can't create an
@Entity
annotation for ObjectBox on my application.Proposed solution
A way to put, get, etc (curd) by
Map<String, Object?>
type.Describe alternatives you've considered
Have not.
Additional context
[empty]