Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Associated object query #694

Open
ForterLi opened this issue Nov 12, 2024 · 4 comments
Open

Associated object query #694

ForterLi opened this issue Nov 12, 2024 · 4 comments
Labels
question How to do something/general question

Comments

@ForterLi
Copy link

  ownerId = \$0 AND (
  (\$1 <= timeAt AND timeAt <= \$2) ||
  (timeAt < \$1 && repeatConfig != nil && (repeatConfig.endAt == nil || repeatConfig.endAt >= \$2) && (
                repeatConfig.repeatType == 1 ||
                repeatConfig.repeatType == 2 && ANY repeatConfig.repeatWeeksValue == \$3
                ))
  ) SORT(createAt DESC)

Filtering of related objects like this, cannot be transferred to objectbox, can not be satisfied, hope to correct

@ForterLi ForterLi added the bug Something isn't working label Nov 12, 2024
@greenrobot-team
Copy link
Member

What you are looking for a probably "link" queries, see https://docs.objectbox.io/queries#query-a-related-entity-links for an example.

Note: I labeled this issue with "more info required" so it will auto-close in a few days if there are no follow-up comments.

@greenrobot-team greenrobot-team added question How to do something/general question more info required Needs more info to become actionable. Auto-closed if no response. and removed bug Something isn't working labels Nov 13, 2024
@ForterLi
Copy link
Author

Need to query current object parameters, with associated object parameters, hybrid query. It is now the associated object that is separate from the current object query.

@github-actions github-actions bot removed the more info required Needs more info to become actionable. Auto-closed if no response. label Nov 14, 2024
@ForterLi
Copy link
Author

ForterLi commented Nov 14, 2024

    final query1 = FLStorageObjectBox.box<TaskModel>().query(TaskModel_.ownerId.equals(OwnerId!) & TaskModel_.timeAt
        .greaterOrEqualDate(selectDate.startOfDay)
         & TaskModel_.timeAt.lessOrEqualDate(selectDate.endOfDay));
    final query2 = FLStorageObjectBox.box<TaskModel>().query(TaskModel_.ownerId.equals(OwnerId!) & TaskModel_.timeAt
        .lessThanDate(selectDate.startOfDay) & TaskModel_.repeatConfig.notNull());
    query2.link(TaskModel_.repeatConfig,
        (TaskConfigModel_.endAt.isNull() | TaskConfigModel_.endAt.greaterOrEqualDate(selectDate.endOfDay)) & 
        (TaskConfigModel_.repeatType.equals(1) | (TaskConfigModel_.repeatType.equals(2) & TaskConfigModel_.repeatWeeksValue.equals(1)))
      );   

Can not query the data in a method, divided into multiple and can not listen and sort, what method can solve this problem, if the Condition class can continue to handle the associated object query, this problem can be solved

@greenrobot-team
Copy link
Member

greenrobot-team commented Nov 18, 2024

can not listen and sort, what method can solve this problem

See https://docs.objectbox.io/data-observers-and-rx#flutter-dart and https://docs.objectbox.io/queries#order-results

Edit: I also added a link in the documentation to make this easier to find: https://docs.objectbox.io/queries#observe-or-listen-to-changes

@greenrobot-team greenrobot-team added the more info required Needs more info to become actionable. Auto-closed if no response. label Nov 18, 2024
@github-actions github-actions bot removed the more info required Needs more info to become actionable. Auto-closed if no response. label Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question How to do something/general question
Projects
None yet
Development

No branches or pull requests

2 participants