Created
May 29, 2013 22:09
-
-
Save jkyamog/5674235 to your computer and use it in GitHub Desktop.
reactive mongo using gridfs to list files
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
import reactivemongo.api.gridfs.Implicits._ | |
def listFiles(docId: String) = Action { | |
Async { | |
listOfFiles(docId).map (files => Ok(files)) | |
} | |
} | |
def listOfFiles(docId: String) = { | |
val files = gridFS.find(BSONDocument("document" -> new BSONObjectID(docId))) | |
files.toList.map { files => | |
val filesId = files map (file => bsonToString(file.id)) | |
Json.toJson(Map("files" ->filesId)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment