Skip to content

Step #7 : Improve Entity syntax

mandubian edited this page Oct 30, 2012 · 5 revisions
      val person = new Namespace("person") {
        val character = Namespace("person.character")
      }

      val weak = AddIdent(Keyword(person.character, "weak"))
      val dumb = AddIdent(Keyword(person.character, "dumb"))

      val id = DId(Partition.USER)

      Datomic.addEntity(id)(
        person / "name" -> "toto",
        person / "age" -> 30L,
        person / "character" -> Seq(weak, dumb)
      ) must beEqualTo(
        AddEntity(id)(
          Keyword(person, "name") -> DString("toto"),
          Keyword(person, "age") -> DLong(30L),
          Keyword(person, "character") -> DSeq(weak.ident, dumb.ident)
        )
      )

      Datomic.addEntity(id)(
        KW(":person/name") -> "toto",
        KW(":person/age") -> 30L,
        KW(""":person/character""") -> Seq(weak, dumb)
      ) must beEqualTo(
        AddEntity(id)(
          Keyword(person, "name") -> DString("toto"),
          Keyword(person, "age") -> DLong(30L),
          Keyword(person, "character") -> DSeq(weak.ident, dumb.ident)
        )
      )