tigrisdata-archive / tigris-client-ts

TypeScript client for Tigris
https://www.tigrisdata.com/docs/sdkstools/typescript/
Apache License 2.0
15 stars 10 forks source link

Filters improvement #268

Closed adilansari closed 1 year ago

adilansari commented 1 year ago

Make Filter<T> more user friendly.

Example

Existing filter spec:

const productsCursor = catalog.findMany({
  filter: {
    op: LogicalOperator.OR,
    selectorFilters: [
      {
        brand: "adidas",
      },
      {
        op: SelectorFilterOperator.LT,
        fields: {
          price: 50,
        },
      },
    ],
  },
});

can be improved to:

const productsCursor = catalog.findMany({
  filter: {
    "$or": [ 
      {  brand: "adidas" },
      {  price: { "$lt": 50 } },
    ],
  },
});
ovaistariq commented 1 year ago

This would be great as it greatly simplifies the filtering syntax.

ovaistariq commented 1 year ago

/bounty 200

algora-pbc[bot] commented 1 year ago

💎 $200.00 bounty created by ovaistariq 👉 To claim this bounty, submit a pull request that includes the text /claim #268 somewhere in its body 📝 To receive payouts, join Algora and complete the relevant onboarding steps 💵 Payment arrives in your account 2-5 days after the bounty is rewarded 💯 You keep 100% of the bounty award 🙏 Thank you for contributing to tigrisdata/tigris-client-ts!

kaf-lamed-beyt commented 1 year ago

Hi @ovaistariq and @adilansari,

I'd love to work on this issue. Can anyone walk me through the process?

I noticed that @adilansari, said in his comment above that, modifying the function to this 👇🏼 would suffice.

const productsCursor = catalog.findMany({
  filter: {
    "$or": [ 
      {  brand: "adidas" },
      { "$lt": { price: 50 } },
    ],
  },
});

Would that be all I need to do?

adilansari commented 1 year ago

Yes. The goal is to simplify filter definition for end users and retain full capability to define complex filters.

And some usage in Tigris official documentation here.

kaf-lamed-beyt commented 1 year ago

Ayy! Great!

I'll have a look, and give you feedback, as soon as possible.

ovaistariq commented 1 year ago

That sounds great.

algora-pbc[bot] commented 1 year ago

💡 kaf-lamed-beyt submitted a pull request that claims the bounty. You can visit your org dashboard to reward.

akhill10 commented 1 year ago

https://github.com/tigrisdata/tigris-client-ts/pull/310#issuecomment-1518662463 @kaf-lamed-beyt Since you've stopped working on this. I will pick this up.

kaf-lamed-beyt commented 1 year ago

Yes, please. That sounds good. 👌🏽

algora-pbc[bot] commented 1 year ago

💡 akhill10 submitted a pull request that claims the bounty. You can visit your org dashboard to reward.

algora-pbc[bot] commented 1 year ago

🎉🎈 @akhill10 has been awarded $200.00! 🎈🎊