CodeLionX / actordb

Actor Database System Framework using Akka
MIT License
0 stars 2 forks source link

Proposal: New creation of relations in dactors #59

Closed CodeLionX closed 6 years ago

CodeLionX commented 6 years ago

Proposed Changes

object Cart {
  object CartInfo extends RelationDef {
    val cartId: ColumnDef[Int] = ColumnDef("c_id")
    val storeId: ColumnDef[Int] = ColumnDef("store_id")
    val sessionId: ColumnDef[Int] = ColumnDef("session_id")

    override val columns: Set[UntypedColumnDef] = Set(cartId, storeId, sessionId)
    override val name: String = "cart_info"
  }
}

class Cart(id: Int) extends Dactor(id) {
  import Cart._

  override protected val relations: Map[RelationDef, MutableRelation] =
    Dactor.createAsRowRelations(Seq(CartInfo, CartPurchases))

  override def receive: Receive = {
    val result = relations(CartInfo).insert(CartInfo.newRecord().build())
  }

}

Related