0

I need to write a Gosu query to list out the records in a table. I use a compare operator to filter out multiple columns based on some criteria. I need to filter out one particular column which is of type array. Eg The table PaymentDetails has a column of CardTypes which is of Array. I need to filter out of cardTypes only with the value "Visa". How do i achieve this?

For eg,

var List = Query.make(PolicyPeriod)
           .compare("Column1" , Equals , true)                      
           .subselect("ID",CompareNotIn,entity.Name,"PolicyPeriod")
                        .join("Entity2")
                        .join("Entity3")
                    ***.compare("CardType" , Equals ,CardType.TC_VISA )***
                        .select()
shaher
  • 17
  • 3

2 Answers2

0

I'm a little confused here as you can't have an array of typekeys off an entity (CardType.TC_VISA implies it's a typekey). You would need some kind of join table between the entity and the typekey. I don't believe you need a subselect here. Additionally, it's best practices to use the following notation

var List = Query.make(PolicyPeriod)
           .compare(PolicyPeriod#Column1 , Equals , true)
           ...
           .join(SomeEntity#PaymentDetails)
           .join(CardTypes#PaymentDetails)
           .compare(CardTypes#CardType, Equals ,CardType.TC_VISA)
           .select()

[PolicyPeriod] -> ... -> [SomeEntity] -> [PaymentDetails] <-* [CardTypes] -> [CardType]

eglease
  • 2,445
  • 11
  • 18
  • 28
Chris Yanaga
  • 66
  • 1
  • 3
0

If you are looking to find all the payments that used Visa or Amex, then you might do a comparison like this. I am not completely sure what you are asking though.

.compareIn(CardTypes#CardType, {CardType.TC_VISA, CardType.TC_AMEX})

This would give you all the payments that were paid via Visa or Amex.