Giter Site home page Giter Site logo

Comments (7)

jonian avatar jonian commented on May 22, 2024 1

Great! I will start working on it in the next days.

from pgrel.

palkan avatar palkan commented on May 22, 2024

What about:

Model.store(:store).path(:name).like('%test%')

?

And I like this option, too:

Model.store(:store).path(:name, '%test%', operator: 'ILIKE')

# or
Model.store(:store).path(:name).op("ILIKE", '%test%')

It could be used for arbitrary operators.

from pgrel.

jonian avatar jonian commented on May 22, 2024

Thanks for the response, I'm ok with any of them. I think the best are:

# will also need methods for unlike, gt, gte, lt, lte
Model.store(:store).path(:name).like('%test%')

Model.store(:store).path(:name).op("ILIKE", '%test%')

Both can be implemented to give more options and avoid SQL operators for the common cases that are covered by the first option.

As I said in my previous comment, I can make a PR for this when you decide what to implement.

from pgrel.

jonian avatar jonian commented on May 22, 2024

After thinking about this a little bit more, I think that converting path to a chain, will require to change the way that path works now, so the best way to do it seems to add the operators in the store chain.

Convert path to chain

# using 
Model.store(:store).path(:name).like('%test%')
Model.store(:store).path(:name).op("ILIKE", '%test%')

# will require to check for `=` with
Model.store(:store).path(:name).eq('test')
Model.store(:store).path(:name).op("=", 'test')

Add operator methods to store chain

# current usage
Model.store(:store).path(:name, 'test')
Model.store(:store).not.path(:name, 'test')

# usage with specific operators
Model.store(:store).like.path(:name, '%test%')
Model.store(:store).not.like.path(:name, '%test%')

# usage with arbitary operator
Model.store(:store).op("LIKE").path(:name, '%test%')
Model.store(:store).not.op("LIKE").path(:name, '%test%')

What do you think?

from pgrel.

palkan avatar palkan commented on May 22, 2024

path(...).like(...) looks more natural than like(...).path(...)

Though converting path into a chain would be hard since we allow arbitrary number of args 🤔

Maybe, we can introduce a new method, say, #at_path:

Model.store(:store).at_path(:name).like('%test%')

from pgrel.

jonian avatar jonian commented on May 22, 2024

To summarize, the available options that are easier to implement and do not require changes in how the gem already works are:

# New operators are always a chain
Model.store(:store).like.path(:name, '%test%')

# Path is a chain when no arguments given
Model.store(:store).path.like(:name, '%test%')

# New method for path chain
Model.store(:store).at_path(:name).like('%test%')

I think all options are good and the decision is up to you @palkan.

from pgrel.

palkan avatar palkan commented on May 22, 2024

Let's continue with the last one: #at_path.

from pgrel.

Related Issues (9)

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.