Git Product home page Git Product logo

Comments (2)

25747 avatar 25747 commented on May 22, 2024

after some playing around I found a valid form of the query i was imagining, and it fit what i was expecting:

.or(`name.ilike.%mason%,where_now.ilike.%mason%`)

i modified the dataprovider's getList function near the end where it checks for a 'q' field to complete the query. Instead of adding on successive .ilike( ) selectors, I build a string and pass it into one or( ) selector at the end:

if (q) {
    let queryString = ""; //create a query string to put into an or( ) selector
    const fullTextSearchFields = Array.isArray(resourceOptions)
      ? resourceOptions
      : resourceOptions.fullTextSearchFields;

    fullTextSearchFields.forEach((field, index, array) => {
      /* query = query.ilike(field, `%${q}%`); */ // existing method - add on successive ilike selectors

      queryString += `${field}.ilike.%${q}%`; // new method - concatenate the ilike queries into one string

      if (index < array.length - 1) {
        queryString += ","; //add commas between the selectors, but not at the end
      }
    });
    query.or(queryString); //add an or( ) selector using the built query string

In the case of above the above example, now my list returns with the two "Players" whose names contain 'mason'. I can also search for 'retired' and find the 8 "Players" with 'retired' in where_now.

I will add in other fields and see if this works like I expect it to. Does this implementation make sense?

from ra-supabase.

djhi avatar djhi commented on May 22, 2024

This has now changed in 2.0.0. See the release notes

from ra-supabase.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.