Guest User

Untitled

a guest
May 22nd, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.59 KB | None | 0 0
  1.  def findByUsername(username: String): User = {
  2.     val mongoConnection = MongoConnection()
  3.     val mongoCollection = mongoConnection("tassili")("users")
  4.    
  5.     val mongoObject = mongoCollection.findOne(MongoDBObject("username" -> username))
  6.  
  7.     val user = new User
  8.     for(x <- mongoObject) {
  9.       user.id = x.getAs[ObjectId]("_id").get
  10.       user.username = x.getAs[String]("username").get
  11.       user.fullname = x.getAs[String]("fullname").get
  12.       user.passwordHash = x.getAs[String]("passwordHash").get
  13.       user.role = x.getAs[String]("role").get
  14.     }
  15.  
  16.     return user
  17.   }
Add Comment
Please, Sign In to add comment