How do I get JSON string from Mongo db using Play (and Salat)?

260 Views Asked by At

How do I get the plain JSON from Mongo DB using Play? (Currently I'm accessing Mongo with Salat because it's the only way I have found yet).

I have currently:

MyEntry.findAll()

Where findAll returns a SalatMongoCursor - I can call something on it like mkString, this shows all the entries but not in JSON format.

Don't want to loop over it or map, there must be a shorthand for this.

This is the dao:

object MyEntry extends ModelCompanion[MyEntry, ObjectId]  {
  val dao = new SalatDAO[MyEntry, ObjectId](collection = mongoCollection("myEntries")) {}
}

This is a bit strange, not being able to get JSON from a JSON database... hopefully I'm just overlooking it.

Thanks in advance.

1

There are 1 best solutions below

0
On

Here’s a small sample app that shows how: https://github.com/hilton/menumod