longevity

A Persistence Framework for Scala and NoSQL

View project on GitHub

repo.delete

Use Repo.delete to remove a persistent object from the database:

val userState: PState[User] = getUserState()
val deleteResult: Future[Deleted[User]] = repo.delete(userState)

Like most of the Repo API calls, Repo.delete requires an implicit parameter longevity.model.PEv[M, P]. This implicit evidence ensures that the type P is actually a persistent class in the domain model.

The delete is complete when the future completes successfully. You cannot do much with the Deleted, but you can have at the persisent object for old times sake:

deleteResult.map { deleted =>
  val deletedUser: User = deleted.get
}

Of course, this value will not be particularly useful, as the persisent object no longer exists in the database.

We would like to support in-database deletes in the future, possibly with something like Repo.deleteByQuery or Repo.deleteByKeyVal.
prev: repo.update
up: the repository
next: persisting polymorphism