简体   繁体   中英

eqs on Option[UUID] type? Phantom + Cassandra + Scala

I'm using Phantom framework to work with Cassandra and I'm trying to do a eqs on a Option field eg.

Address.select.where(_.id eqs Some(uuid)).one()

Then I get "value eqs is not a member of object"

is there a way to accomplish that? I can't figure out...

The id field is an Option[UUID], because it must be null when I'm receiving a POST request in Play Framework, but I don't know how to do this assert in phantom

I also opened an issue on github.

https://github.com/websudos/phantom/issues/173

Using the

import com.websudos.phantom.Implicits._

works!!!

Phantom relies on a series of implicit conversions to provide most of the functionality. A very simple way to fix most of the errors you get from compiling phantom tables is to make sure the relevant import is in scope.

Before phantom 1.7.0

import com.websudos.phantom.Implicits._

After 1.7.0

import com.websudos.phantom.dsl._

Beyond the implicit mechanism, phantom will also help you with aliases to a vast number of useful objects in Cassandra:

  • Phantom connectors
  • Cassandra Consistency Levels
  • Keyspaces

Using a potentially null value as part of a PRIMARY KEY in CQL is also wrong as no part of the CQL primary can be null . It's a much better idea to move processing logic outside of phantom.

Traditionally, a tables -> db service -> api controller -> api approach is the way to build modular applications with better separation of concerns. It's best to keep simple I/O at table level, app level consistency at db service level, and all processing logic at a higher level.

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM