Created
June 9, 2011 15:20
-
-
Save bwmcadams/1016955 to your computer and use it in GitHub Desktop.
Defaults + Type Classes
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
/** | |
* Attempting to factor this method (Which used to take a hard argument for Qry of BSONDocument | |
* to use a type class, where the type class object SerializableBSONObject knows how to encode/decode the | |
* Document represented in Qry | |
* | |
* I was ***hoping*** That the Scala compiler would be smart enough to extract the type class type | |
* in the case of a Default Argument but it seems not. | |
* The compiletime error is: | |
* | |
* could not find implicit value for evidence parameter of type org.bson.SerializableBSONObject[Nothing] | |
* | |
* A cookie and/or mug of tasty beer for anyone who has clever ideas that don't involve | |
* java style overloaded methods | |
*/ | |
def findAndRemove[Qry : SerializableBSONObject](db: String)(collection: String)(query: Qry = Document.empty) = findAndModify(db)(collection)(query=query, remove=true)_ |
My guess is it's the usage of findAndModify that's burning you here.
Ya, I found the problem.
findAndModify has a default value for an Update parameter of Option[T] =
None
I changed it to Option[T] = Option[Document](null)
That fixes it ;)
…On Thu, Jun 9, 2011 at 12:21 PM, jsuereth < ***@***.***>wrote:
My guess is it's the usage of findAndModify that's burning you here.
##
Reply to this email directly or view it on GitHub:
https://gist.github.com/1016955
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am not seeing the
org.bson.SerializableBSONObject[Nothing]
.