A way to remove collection.flatMap from every query
jyotman opened this issue · 1 comments
jyotman commented
Hi, I was wondering if there's a way to resolve the collection Future. If in Todo.scala model, this -
def collection: Future[JSONCollection]
could be converted to -
def collection: JSONCollection
Then in every query we could remove the collection.flatMap
.
Example -
def addTodo(todo: Todo): Future[WriteResult] = {
collection.flatMap(_.insert(todo))
}
would become -
def addTodo(todo: Todo): Future[WriteResult] = {
collection.insert(todo)
}
ricsirigu commented
@jyotman yes you can but you shouldn't.
You can call .result
on the future or use scala-async