3

I have a Cassandra table Department with columns name_list extends ListColumn[String] and id extends StringColumn with PartitionKey.

I want to fetch id where the requested name is present in name_list.

I tried using in operator select(_.id).where(name in name_list) but it is not working.

Another query I tried select(_.id).where(_.name_list contains name) but it is also not working for me.

 def getByName(name: String) = {
    select(_.id, _.name_list).where(_.name_list contains name)   
}

Is there any way to solve this!!

Charmy Garg
  • 291
  • 2
  • 14

1 Answers1

2

You can use the SetColumn as the type for you column then you will be able to use the contains method. Use this

name_list extends SetColumn[String]

then this will work fine

def getByName(name: String) = {
    select(_.id, _.name_list).where(_.name_list contains name)   
}

Thanks

Akash Sethi
  • 2,284
  • 1
  • 20
  • 40