objectbox-java icon indicating copy to clipboard operation
objectbox-java copied to clipboard

Support list/array type properties

Open greenrobot opened this issue 8 years ago • 18 comments
trafficstars

It should be easy to implement properties of type int[] or List<String>.

Affects also queries however:

  • how is something like "greater than X" defined? All values? At least one value? Maybe we would need additional info here

greenrobot avatar Jan 24 '17 23:01 greenrobot

That's the dealbreaker for me at the moment.

Do you have a timeframe in mind when this feature will be added?

While we're at it: I'd also love to see support for Sets and Maps

homj avatar Jan 26 '17 22:01 homj

@homj No timeline yet. Might be quick depending on its relevance for to-many relations. But cannot promise yet. Will keep Sets and Maps in mind - if it's not too complicated, maybe we can just implement everything at once.

What are your requirements excatly, do you also need to query for array/list/set/map values? If so, how (== >, !=, IN, contains, all, etc.)?

Be aware that this will be only offered for built-in types (integers, floating, and strings).

greenrobot avatar Jan 27 '17 08:01 greenrobot

Coming from realm, which has the same issue, this would be a major addition that saves us from writing boilderplate code.

The main use case(for me) is when we convert json to POJOs and the json contains a list of strings/primitives.

To be able to query the list values would be nice, but just storing it is enough for me.

ArthurSav avatar Feb 25 '17 22:02 ArthurSav

What's the status on this? It's been 85 years

ArthurSav avatar Nov 10 '17 11:11 ArthurSav

We are committed to this. Timing wise we have prioritized other features the next 2 months. For storing, you can use a converter today.

greenrobot avatar Nov 10 '17 11:11 greenrobot

Hi Markus, any updates on this one?

fr-johannes avatar Apr 26 '18 04:04 fr-johannes

We don't usually comment on time estimates. However, here's an exception to the rule: we try to be be quicker than that:

It's been 85 years

greenrobot avatar Apr 26 '18 10:04 greenrobot

Definite push for this one, would be a huge plus for me to not have to create 30+ custom converter classes! Keep up the good work Markus

cflannery91 avatar May 26 '18 12:05 cflannery91

If you'll finally implement this feature, I swear I'll buy you a coffee! ☕

gryphon2411 avatar Oct 23 '18 15:10 gryphon2411

Any update on this feature?

jonathansds avatar Mar 24 '19 14:03 jonathansds

It's nearly been 2 years, and no progress

sanjeevyadavIT avatar Oct 17 '19 07:10 sanjeevyadavIT

I will have to move to another database lib because of this :(

gyorgygabor avatar Dec 05 '19 09:12 gyorgygabor

That will be better, frankly I have used room & Objectbox both, I will choose room over ObjectBox everytime

sanjeevyadavIT avatar Dec 05 '19 10:12 sanjeevyadavIT

@gyorgygabor @alexakasanjeev Note: similar to Room's @TypeConverter you can already use the @Convert annotation (on a property). Though granted, it only supports lists and not arrays as @Convert requires a converter implementation instead of an annotated method.

greenrobot-team avatar Dec 09 '19 07:12 greenrobot-team

Adding to @greenrobot-team 's comment, if you are using Kotlin it's very easy to write a generic converter and then add new converter classes in one liners like

class CustomConverterA : StringConverter<List<CustomObject>> by listConverter()

Provided you want to use the same serialization mechanism every time, of course.

fr-johannes avatar Dec 16 '19 00:12 fr-johannes

@greenrobot Hello,

Would this work with ObjectBox?

class Hub {
    List<Schedule> schedules; 
}
class Schedule {
    String day;
    LocalTime opens;
    LocalTime closes;
}

And then query those Hubs which opens and closes during a specific day, say, query with this constraint:

new Schedule().builder()
    .day("Monday")
    .opens(LocalTime.parse("08:00")
    .close(LocalTime.parse("17:00").build();

So in this case we want to query for Hubs that are open on Mondays at 8am to 5pm.

cyberquarks avatar Dec 24 '20 14:12 cyberquarks

@cyberquarks this is somewhat offtopic, please check the docs on queries, relations and links. Especially here: https://docs.objectbox.io/queries#add-query-conditions-for-related-entities-links

greenrobot avatar Dec 29 '20 14:12 greenrobot

A little update: 3.0 (released today) makes the first step by supporting String lists/arrays. Query support is limited to "contains an element matching a given value".

Leaving queries aside, basic support for primitive type lists would be the next step.

greenrobot avatar Oct 19 '21 17:10 greenrobot