0

I am new to object box. I am struggling on finding a way to pass parameters to my query. i looked at the documentation but still struggling.

this is my code

late Stream<List<dynamic>> _stream;

_stream =  _Mystore
        .box<Income>()
        .query()
        .watch(triggerImmediately: true)
        .map((query) => query.find());

return StreamBuilder<List<dynamic>>(
      stream: _stream,
      builder: (context, snapshot) {
        final activeIncomes = snapshot.data;

        if (!snapshot.hasData || activeIncomes!.length == 0) {
          return  Align(
              alignment: Alignment.center,
              child: noData()
          );
        }
        return itemList(activeIncomes!);
      },
    );

the above query will get all the rows from entity Income. however, i want to filter the rows by passing parameters value. I tried the following but didnt work

late Stream<List<dynamic>> _stream;

_stream =  _Mystore
        .box<Income>()
        .query()
        .watch(triggerImmediately: true)
        .map((query) => query.param.(Income_.monthNumber.equals(6))find());


i added param.(Income_.monthNumber.equals(6) to query but i get error. The argument type 'Condition' can't be assigned to the parameter type 'QueryProperty<dynamic, dynamic>'.

can someone help me and show me how to add parameters to query in objectbox so that i can use that query with my stream?

thanks

1 Answer 1

1

Pass conditions to the query() method. Using your example:

box().query(Income_.monthNumber.equals(6))

Source: https://docs.objectbox.io/queries

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.