Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def findByUsername(username: String): User = {
- val mongoConnection = MongoConnection()
- val mongoCollection = mongoConnection("tassili")("users")
- val mongoObject = mongoCollection.findOne(MongoDBObject("username" -> username))
- val user = new User
- for(x <- mongoObject) {
- user.id = x.getAs[ObjectId]("_id").get
- user.username = x.getAs[String]("username").get
- user.fullname = x.getAs[String]("fullname").get
- user.passwordHash = x.getAs[String]("passwordHash").get
- user.role = x.getAs[String]("role").get
- }
- return user
- }
Add Comment
Please, Sign In to add comment