tekartik / sembast.dart

Simple io database
BSD 2-Clause "Simplified" License
780 stars 64 forks source link

How do I chain/make compound filters? #353

Closed daveshirman closed 1 year ago

daveshirman commented 1 year ago

The documentation is really unclear whether it's possible to do this.

Where:

Something like this:

    final finder = Finder(
      filter: Filter.and([
        Filter.or([
          Filter.matchesRegExp(
            'clientName',
            RegExp(searchText ?? "", caseSensitive: false),
          ),
          Filter.matchesRegExp(
            'buildingName',
            RegExp(searchText ?? "", caseSensitive: false),
          ),
        ]),
        Filter.greaterThanOrEquals('job_First_Start_Date_Int', startDateInt),
        Filter.lessThanOrEquals('job_First_Start_Date_Int', endDateInt),
      ]),
      sortOrders: [SortOrder('buildingName')],
    );

It should be updated to make clear how to do compound and and or filters.

Thanks

alextekartik commented 1 year ago

That looks like a perfect filter to me. I know the documentation is poor, sorry, especially on the filter section. I look into getting it better but PRs are always welcome. For example I might use your example as an example (I will likely replace the date with Timestamp for demonstration purpose) if that's ok for you.

alextekartik commented 1 year ago

I have added more document here: https://github.com/tekartik/sembast.dart/blob/master/sembast/doc/queries.md#filtering-and-sorting

and added an example close to what you have provided.

daveshirman commented 1 year ago

No worries and thanks very much. Hopefully it helps other people too. Cheers.

On Thu, Apr 20, 2023, 05:45 Alexandre Roux @.***> wrote:

I have added more document here: https://github.com/tekartik/sembast.dart/blob/master/sembast/doc/queries.md#filtering-and-sorting

and added an example close to what you have provided.

— Reply to this email directly, view it on GitHub https://github.com/tekartik/sembast.dart/issues/353#issuecomment-1516034763, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADM6KXWJK4536222WBFWU63XCEATZANCNFSM6AAAAAAXENZC3U . You are receiving this because you authored the thread.Message ID: @.***>