Last active
December 14, 2015 09:29
-
-
Save stephanos/5064821 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
error: value where is not a member of BaseMeta[_] with BaseDoc[_] | |
doc.where(_._id eqs 42) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.foursquare.rogue.LiftRogue._ | |
import net.liftweb.mongodb.record.{MongoRecord, MongoMetaRecord} | |
// ==== BASE | |
trait BaseDoc[T <: MongoRecord[T]] | |
extends MongoRecord[T] { | |
self: T => | |
object id | |
} | |
trait BaseMeta[T <: BaseDoc[T]] | |
extends MongoMetaRecord[T] { | |
self: T => | |
} | |
// ==== DOC #1 | |
class BaseDoc1 extends BaseDoc[BaseDoc1] { | |
def meta = BaseMeta1 | |
} | |
object BaseMeta1 extends BaseDoc1 with BaseMeta[BaseDoc1] | |
// ==== DOC #2 | |
class BaseDoc2 extends BaseDoc[BaseDoc2] { | |
def meta = BaseMeta2 | |
} | |
object BaseMeta2 extends BaseDoc2 with BaseMeta[BaseDoc2] | |
// ==== QUERY | |
case class Mod(num: Int) { | |
def doc: BaseMeta[_] with BaseDoc[_] = // WRONG | |
num % 2 match { | |
case 0 => BaseMeta1 | |
case _ => BaseMeta2 | |
} | |
} | |
object Main { | |
val doc = Mod(0).doc | |
doc.where(_._id eqs 42) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment