Skip to content

Instantly share code, notes, and snippets.

@pollingj
Created May 21, 2013 13:57
Show Gist options
  • Save pollingj/5619969 to your computer and use it in GitHub Desktop.
Save pollingj/5619969 to your computer and use it in GitHub Desktop.
package uk.co.cd4i.cityplan.domain.mongo
import java.util.Date
import com.novus.salat.annotations._
import com.novus.salat.dao.SalatDAO
import com.mongodb.casbah.Imports._
import com.novus.salat.global._
case class Milestone (
@Key("_id") id: Object = new ObjectId,
projectId: ObjectId,
name: String,
date: Date
)
object Milestone {
def apply(milestone: Milestone, projectId: String) = {
new Milestone(new ObjectId, new ObjectId(projectId), milestone.name, milestone.date)
}
}
object MilestoneDao extends SalatDAO[ Milestone , ObjectId ](collection = MongoConnection()("my_db")("milestones"))
///
Within a controller I have this
get("/:id/milestones", summary("Get a specific project's milestones"),
nickname("getProjectMilestones"),
responseClass("Milestone"),
endpoint("{id}/milestones"),
parameters(
Parameter("id", "ID of project that you want the milestones for",
DataType.String,
paramType = ParamType.Path))) {
MilestoneService.findByProjectId(params("id"))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment