Created
July 2, 2012 22:16
-
-
Save rjenkins/3036082 to your computer and use it in GitHub Desktop.
FindFor2i
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
def findFor2i(index: String, value: String, converter: Converter[T]): List[T] = { | |
get2iResults(getStringKeys(index, value), converter) | |
} | |
// Find all records of Type T for Matching 2i query | |
private def getStringKeys(index: String, value: String): List[String] = { | |
fetchBucket.fetchIndex(BinIndex.named(index)).withValue(value).execute().toList | |
} | |
private def get2iResults(keys: List[String], converter: Converter[T]): List[T] = { | |
val listBuffer = new ListBuffer[T] | |
keys.foreach({ key => listBuffer.prepend(converter.toDomain(fetchBucket.fetch(key).execute()))}) | |
listBuffer.toList | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment