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
class ConnectionScarango { | |
implicit val ec: scala.concurrent.ExecutionContext = scala.concurrent.ExecutionContext.global | |
Profig.initConfiguration().map { in => println(in) } | |
lazy val db = new ArangoDB(credentials = Some(Credentials("root", "jctaurys"))) | |
lazy val dbExample = db.api.db("example") | |
//lazy val collection = dbExample.collection("proveedores") | |
} | |
class CRecipeScarango extends ConnectionScarango { | |
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] | |
} | |
} | |
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] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment