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()
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]