Created
May 3, 2021 14:55
-
-
Save elyphas/6ab5f5d51ce46abfa4fb7fcb00e0978a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/* ArangoDB | |
db.tblrecipe.document("2021-88888") | |
{ | |
"_key" : "2021-88888", | |
"_id" : "tblrecipe/2021-88888", | |
"_rev" : "_cRMJ_Yi---", | |
"fiscal_period" : 2021, | |
"folio" : "88888", | |
"date" : 1620049658325, | |
"id_area" : "3", | |
"area" : "JURISDICCION SANITARIA 03", | |
"servicio" : "CONSULTA" | |
} | |
*/ | |
def insert(item: Recipe) = { | |
lazy val collection = dbExample.collection("tblrecipe") | |
val itemUpdated = item.copy( _id = Recipe.id(item.fiscal_period + "-" + item.folio)) | |
for { | |
_ <- db.init() | |
res <- collection.document.insertOne(itemUpdated) | |
} yield ((item, FoundDoobie())).asRight[String] | |
} | |
def byId(item: Recipe): Future[Either[String, (Recipe, EventsDoobieResult)]] = { | |
lazy val collection = dbExample.collection("tblrecipe") | |
val identi = item.fiscal_period + "-" + item.folio | |
for { | |
_ <- db.init() | |
res <- collection.document.get[Recipe](Recipe.id(identi)) | |
} yield res match { | |
case Some(i) => (res.get, FoundDoobie()).asRight[String] | |
case None => (Recipe(), NotFoundDoobie()).asRight[String] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment