PageRenderTime 183ms queryTime 45ms sortTime 0ms getByIdsTime 74ms findMatchingLines 15ms

100+ results results for 'MongoDBObject find lang:Scala' (183 ms)

Not the results you expected?
CMS.scala https://github.com/delving/culture-hub.git | Scala | 216 lines
                    
32          {
                    
33            if (organizationServiceLocator.byDomain.isAdmin(configuration.orgId, connectedUser) || Group.dao.count(MongoDBObject("users" -> connectedUser, "grantType" -> CMSPlugin.ROLE_CMS_ADMIN.key)) > 0) {
                    
34              action(request)
                    
86      implicit request =>
                    
87        def menuEntries = MenuEntry.dao.findEntries(menu)
                    
88
                    
92          case Some(key) =>
                    
93            val versions = CMSPage.dao.findByKeyAndLanguage(key, language)
                    
94            if (versions.isEmpty) {
                    
167      implicit request =>
                    
168        CMSPage.dao.find(MongoDBObject("key" -> key, "lang" -> language)).$orderby(MongoDBObject("_id" -> -1)).limit(1).toList.headOption match {
                    
169          case None => NotFound(key)
                    
190  def apply(cmsPage: CMSPage, menu: String)(implicit configuration: OrganizationConfiguration): CMSPageViewModel = {
                    
191    // we only allow linking once to a CMSPage so we can be sure that we will only ever find at most one MenuEntry for it
                    
192    val (menuEntryPosition, menuKey) = MenuEntry.dao.findOneByTargetPageKey(cmsPage.key).map { e =>
                    
                
DataStoreOperations.scala https://github.com/SINTEF-9012/sensapp.git | Scala | 181 lines
                    
48import com.mongodb.casbah.Imports._
                    
49import com.mongodb.casbah.commons.MongoDBObjectBuilder
                    
50import com.mongodb.util.JSON
                    
84  def pull(id: Criterion): Option[T] = {
                    
85    val dbResult = _collection.findOne(MongoDBObject(id._1 -> id._2))
                    
86    dbResult match {
                    
115  def retrieve(criteria: List[(String, Any)]): List[T] = {
                    
116    val prototype = MongoDBObject.newBuilder
                    
117    criteria foreach { c => prototype += (c._1 -> c._2) }
                    
117    criteria foreach { c => prototype += (c._1 -> c._2) }
                    
118    _collection.find(prototype.result).toList map { toDomainObject(_) }
                    
119  }
                    
                
ResponseServiceTest.scala https://github.com/cyrusinnovation/inquisition.git | Scala | 128 lines
                    
6import org.scalatest.{BeforeAndAfterEach, FunSuite}
                    
7import com.mongodb.casbah.commons.MongoDBObject
                    
8import com.mongodb.casbah.MongoConnection
                    
25    override def beforeEach() {
                    
26        db("questions").remove(MongoDBObject())
                    
27    }
                    
101
                    
102    test("can find question by id") {
                    
103        val question = createSavedQuestion()
                    
105
                    
106        val retrievedResponse = service.findById(response.id.get)
                    
107
                    
112        evaluating {
                    
113            service.findById(null)
                    
114        } should produce[IllegalArgumentException]
                    
                
MongoTagRepository.scala https://github.com/cyrusinnovation/inquisition.git | Scala | 93 lines
                    
17    tags.ensureIndex(MongoDBObject("_id" -> 1))
                    
18    questions.ensureIndex(MongoDBObject("tags" -> 1))
                    
19
                    
24
                    
25    def findUniqueTagNamesOrderedByTagName(): List[String] = {
                    
26        questions.distinct("tags").map(x => x.toString).sortBy(x => x).toList
                    
29    def findQuestionsByTag(tag: String): List[Question] = {
                    
30        val results = questions.find(MongoDBObject("tags" -> tag))
                    
31        results.map(db2question).toList
                    
58
                    
59        val commandBuilder = MongoDBObject.newBuilder
                    
60        commandBuilder += "mapreduce" -> "questions"
                    
65
                    
66        val tagList = tags.find().sort(MongoDBObject("value" -> -1)).limit(numberToRetreive)
                    
67        val map = tagList map { t => t.getAs[String]("_id").get -> t.getAs[Double]("value").get }
                    
                
MongoTagsRepositoryTest.scala https://github.com/cyrusinnovation/inquisition.git | Scala | 176 lines
                    
9import org.scalatest.junit.JUnitRunner
                    
10import com.mongodb.casbah.commons.MongoDBObject
                    
11
                    
20    override def beforeEach() {
                    
21        db("tags").remove(MongoDBObject())
                    
22        db("questions").remove(MongoDBObject())
                    
29
                    
30    test("find all unqiue question tags") {
                    
31        questionRepository.save(uniqueQuestion().copy(tags = List("java", "spring")));
                    
32        questionRepository.save(uniqueQuestion().copy(tags = List("scala", "spring")));
                    
33        questionRepository.findQuestionCount() should equal(2)
                    
34        val uniqueTags = tagRepository.findUniqueTagNamesOrderedByTagName()
                    
38
                    
39    test("find most popular tags") {
                    
40        val correctQuestion = questionRepository.save(uniqueQuestion().copy(tags = List("java", "spring")));
                    
                
GenericGridFS.scala git://github.com/mongodb/casbah.git | Scala | 195 lines
                    
58  /** Find by query */
                    
59  def find[A <% DBObject](query: A): mutable.Buffer[MongoGridFSDBFile] = underlying.find(query).asScala
                    
60
                    
61  /** Find by query - returns a single item */
                    
62  def find(id: ObjectId): MongoGridFSDBFile = underlying.find(id)
                    
63
                    
64  /** Find by query  */
                    
65  def find(filename: String): mutable.Buffer[MongoGridFSDBFile] = underlying.find(filename).asScala
                    
66
                    
89@BeanInfo
                    
90abstract class GenericGridFSFile(override val underlying: MongoGridFSFile) extends MongoDBObject with Logging {
                    
91  type DateType
                    
                
MongoQuestionRepositoryTest.scala https://github.com/cyrusinnovation/inquisition.git | Scala | 324 lines
                    
9import org.scalatest.junit.JUnitRunner
                    
10import com.mongodb.casbah.commons.MongoDBObject
                    
11import java.lang.String
                    
21    override def beforeEach() {
                    
22        db("questions").remove(MongoDBObject())
                    
23    }
                    
34        savedQuestion.id should be('defined)
                    
35        val retrievedQuestion = repository.findById(savedQuestion.id.get).get
                    
36        retrievedQuestion.id should be(savedQuestion.id)
                    
44
                    
45        val questionCount = repository.findQuestionCount()
                    
46        questionCount should be(3)
                    
54        val updatedQuestion = repository.save(savedQuestion.copy(title = "Updated Title"))
                    
55        val questionCount = repository.findQuestionCount()
                    
56
                    
                
User.scala https://gitlab.com/guodman/webcbv | Scala | 122 lines
                    
60  def save = {
                    
61    var builder = MongoDBObject.newBuilder
                    
62    builder += "_id" -> _id
                    
93  def get(id: ObjectId): User = {
                    
94    dbCollection.findOneByID(id).map({ dbobj => factory(dbobj) }).getOrElse[User](null)
                    
95  }
                    
105  def getByUsername(username: String): User = {
                    
106    val r = dbCollection.findOne(MongoDBObject("username" -> ("(?i)" + username).r))
                    
107    return r.map(factory(_)).headOption.getOrElse[User](null)
                    
110  def all: List[User] = {
                    
111    dbCollection.find.map({ dbobj => factory(dbobj) }).toList
                    
112  }
                    
                
MongoDB.scala https://github.com/SINTEF-9012/sensapp.git | Scala | 238 lines
                    
60  def content: List[String]  = {
                    
61    val data = metadata.find(MongoDBObject.empty, MongoDBObject("s" -> 1))
                    
62    val it = data map {e => e.getAs[String]("s").get }
                    
66  def exists(sensor: String): Boolean = {
                    
67    metadata.findOne(MongoDBObject("s" -> sensor), MongoDBObject("s" -> 1)) != None
                    
68  }
                    
77  def describe(sensor: String, prefix: String): Option[SensorDatabaseDescriptor] = {
                    
78    metadata.findOne(MongoDBObject("s" -> sensor)) match {
                    
79      case None => None
                    
81        val schema = getSchema(sensor)
                    
82        val size = data.find(MongoDBObject("s" -> sensor)).size
                    
83        val obj = SensorDatabaseDescriptor(sensor, schema, size, prefix+sensor)
                    
148      case "asc"  => {data.find(query).sort(MongoDBObject("t" -> 1)) }
                    
149      case "desc" => {data.find(query).sort(MongoDBObject("t" -> -1))}
                    
150    }
                    
                
Mr00.scala http://scaly.googlecode.com/svn/trunk/ | Scala | 131 lines
                    
32import com.mongodb.casbah.MongoConnection
                    
33import com.mongodb.casbah.commons.MongoDBObject
                    
34import com.mongodb.casbah.MongoCursor
                    
84    
                    
85    val portfsQuery = MongoDBObject("id" -> portfId)
                    
86
                    
86
                    
87    val portfsCursor : MongoCursor = portfsCollecton.find(portfsQuery)
                    
88    
                    
95    val value = bondIds.foldLeft(0.0) { (sum, id) =>
                    
96      val bondsQuery = MongoDBObject("id" -> id)
                    
97
                    
97
                    
98      val bondsCursor: MongoCursor = bondsCollection.find(bondsQuery)
                    
99
                    
                
Par03.scala http://scaly.googlecode.com/svn/trunk/ | Scala | 213 lines
                    
33import com.mongodb.casbah.MongoConnection
                    
34import com.mongodb.casbah.commons.MongoDBObject
                    
35import com.mongodb.casbah.MongoCursor
                    
142    
                    
143    val portfsQuery = MongoDBObject("id" -> portfId)
                    
144
                    
144
                    
145    val portfsCursor : MongoCursor = portfsCollecton.find(portfsQuery)
                    
146    
                    
158      // Get the bond from the bond collection
                    
159      val bondQuery = MongoDBObject("id" -> bondId.portfId)
                    
160
                    
160
                    
161      val bondCursor: MongoCursor = bondsCollection.find(bondQuery)
                    
162
                    
                
MongoQuestionRepository.scala https://github.com/cyrusinnovation/inquisition.git | Scala | 81 lines
                    
15    val questions = db("questions")
                    
16    questions.ensureIndex(MongoDBObject("responses.id" -> 1))
                    
17    questions.ensureIndex(MongoDBObject("tags.name" -> 1))
                    
27                val dbObj = grater[Question].asDBObject(question)
                    
28                questions.update(MongoDBObject("_id" -> new ObjectId(id)), dbObj, false, false, WriteConcern.Safe)
                    
29                question.copy(id = Some(dbObj("id").toString))
                    
38
                    
39    def findById(id: String): Option[Question] = {
                    
40        val result: Option[DBObject] = questions.findOneByID(new ObjectId(id))
                    
46    def findRecent(limit: Int): List[Question] = {
                    
47        val results = questions.find().limit(limit) map (db2question)
                    
48        results.toList
                    
71    def findResponseQuestion(responseId: String): Option[Question] = {
                    
72        questions.findOne(MongoDBObject("responses.id" -> responseId))
                    
73                .map(db2question(_))
                    
                
RRDBaseRegistry.scala https://github.com/SINTEF-9012/sensapp.git | Scala | 177 lines
                    
92    val result = new ArrayList[String]()
                    
93    val q  = MongoDBObject.empty
                    
94    val fields = MongoDBObject("path" -> 1)
                    
94    val fields = MongoDBObject("path" -> 1)
                    
95    val res = rrd4jcollection.find(q, fields)
                    
96
                    
105    // Had to query the DB . No method in the RRD4J APIs.
                    
106    val query = MongoDBObject("path" -> path)
                    
107    val rrdObject = rrd4jcollection.findOne(query);
                    
                
MongoDBPersistence.scala https://github.com/andreaskc/orbeon-forms.git | Scala | 305 lines
                    
137        withCollection(app, form) { coll =>
                    
138            coll.findOne(MongoDBObject(DOCUMENT_ID_KEY -> documentId)) match {
                    
139                case Some(result: DBObject) =>
                    
196        withCollection(app, form) { coll =>
                    
197            coll.findOne(MongoDBObject(FORM_KEY -> form)) match {
                    
198                case Some(result: DBObject) =>
                    
256                    // Keyword search
                    
257                    coll.find(MongoDBObject(KEYWORDS_KEY -> fullQuery))
                    
258                } else {
                    
259                    // Structured search: gather all non-empty <query name="$NAME">$VALUE</query>
                    
260                    coll.find(MongoDBObject(searchElem.tail filter (elemValue(_) nonEmpty) map (e => (attValue(e, "name") -> elemValue(e))) toList))
                    
261                }
                    
264            val resultsToSkip = (pageNumber - 1) * pageSize
                    
265            val rows = find sort MongoDBObject(LAST_UPDATE_KEY -> -1) skip resultsToSkip limit pageSize
                    
266
                    
                
QuestionServiceImplTest.scala https://github.com/cyrusinnovation/inquisition.git | Scala | 203 lines
                    
9import com.cyrusinnovation.inquisition.questions.mongodb.{MongoTestConstants, MongoQuestionRepository}
                    
10import com.mongodb.casbah.commons.MongoDBObject
                    
11import java.security.InvalidParameterException
                    
24    override def beforeEach() {
                    
25        db("questions").remove(MongoDBObject())
                    
26    }
                    
37        savedQuestion.id should be('defined)
                    
38        val retrievedQuestion = service.findById(savedQuestion.id.get)
                    
39        retrievedQuestion.id should be(savedQuestion.id)
                    
43        evaluating {
                    
44            service.findById(MongoTestConstants.DeadObjectIdString)
                    
45        } should produce[IllegalArgumentException]
                    
54        savedQuestion.id should be('defined)
                    
55        repository.findById(savedQuestion.id.get) should be('defined)
                    
56
                    
                
MaxTimeSpec.scala git://github.com/mongodb/casbah.git | Scala | 131 lines
                    
49          MongoDBObject("$match" -> ("score" $gte 7)),
                    
50          MongoDBObject("$project" -> MongoDBObject("score" -> 1))
                    
51        ),
                    
58    "be supported by findAndModify" in {
                    
59      lazy val findAndModify = collection.findAndModify(query = MongoDBObject("_id" -> 1), fields = MongoDBObject(),
                    
60        sort = MongoDBObject(), remove = false, update = MongoDBObject("a" -> 1),
                    
66    "be supported by cursors" in {
                    
67      val cursor = collection.find().maxTime(oneSecond)
                    
68      cursor.next() should throwA[MongoExecutionTimeoutException]
                    
72    "be supported when calling findOne" in {
                    
73      lazy val op = collection.findOne(MongoDBObject.empty, MongoDBObject.empty,
                    
74        MongoDBObject.empty, ReadPreference.Primary,
                    
94    "be supported when calling a chained count" in {
                    
95      lazy val op = collection.find().maxTime(oneSecond).count()
                    
96      op should throwA[MongoExecutionTimeoutException]
                    
                
Books.scala https://github.com/koduki/eBookSearch.git | Scala | 224 lines
                    
35
                    
36        val another = BookDao.find(MongoDBObject("isbn" -> isbn)).toList
                    
37        debug("books count is %s".format(another.size))
                    
59  def select(item: Item): Book = {
                    
60    val books = BookDao.find(MongoDBObject("items" -> grater[Item].asDBObject(item))) toList
                    
61    val result = if (books.isEmpty) {
                    
76    FeedItemDao
                    
77      .find((MongoDBObject("_id.provider" -> grater[Provider].asDBObject(provider))))
                    
78      .sort(orderBy = MongoDBObject("createdAt" -> -1))
                    
137      val result = selectBestFitBook(item, results)
                    
138      val books = BookDao.find(MongoDBObject("isbn" -> result.isbn)).toList
                    
139      if (books.isEmpty) {
                    
214    nativeBooks.distinct("isbn", "isbn" $ne "").foreach { (isbn) =>
                    
215      val books = BookDao.find(MongoDBObject("isbn" -> isbn)).toList
                    
216      info("isbn is %s, count %d".format(isbn, books.size))
                    
                
NPortfolio02.scala http://scaly.googlecode.com/svn/trunk/ | Scala | 179 lines
                    
33import com.mongodb.casbah.MongoConnection
                    
34import com.mongodb.casbah.commons.MongoDBObject
                    
35import com.mongodb.casbah.MongoCursor
                    
143    
                    
144    val portfsQuery = MongoDBObject("id" -> portfId)
                    
145
                    
145
                    
146    val portfsCursor : MongoCursor = portfsCollecton.find(portfsQuery)
                    
147    
                    
156      // Get the bond from the bond collection
                    
157      val bondQuery = MongoDBObject("id" -> id)
                    
158
                    
158
                    
159      val bondCursor: MongoCursor = bondsCollection.find(bondQuery)
                    
160
                    
                
storage.scala https://github.com/scalaby/oauth.git | Scala | 87 lines
                    
16  override def getConsumer(key: String) = {
                    
17     self.consumers.findOne(MongoDBObject("consumerKey" -> key)).map((request) => {
                    
18         Consumer(key, request("consumerSecret").toString)
                    
24         case TokenRequest(consumer,  callback, token, tokenSecret) => {
                    
25	    MongoDBObject("consumerKey" -> consumer.consumerKey, 
                    
26	                   "callback" -> callback,
                    
31	 case VerificationRequest(consumer, callback, verifier, token, tokenSecret) => {
                    
32	    MongoDBObject("consumerKey" -> consumer.consumerKey,
                    
33	                  "callback" -> callback,
                    
52  override def get(key: String) = {
                    
53     val p = self.requests.find(MongoDBObject("token" -> key))
                    
54                 .sort(MongoDBObject("_id" -> -1)).limit(1)
                    
82  override def getNonces(timestamp: String): Set[String] = {
                    
83     nonces.find(MongoDBObject("timestamp" -> timestamp)).map( (resp) => {
                    
84         resp("nonce").toString
                    
                
MongoResponseRepository.scala https://github.com/cyrusinnovation/inquisition.git | Scala | 80 lines
                    
6import org.springframework.beans.factory.annotation.Autowired
                    
7import com.mongodb.casbah.commons.MongoDBObject
                    
8import org.springframework.stereotype.Repository
                    
28    def save(questionId: String, response: Response): Response = {
                    
29        questionRepository.findById(questionId) match {
                    
30            case None => {
                    
60    def getResponse(responseId: String): Option[(Question, Response)] = {
                    
61        questionRepository.findResponseQuestion(responseId) match {
                    
62            case Some(x: Question) => {
                    
                
ReminderSnips.scala https://bitbucket.org/ta_jim/lift_userlogin_template.git | Scala | 167 lines
                    
22import net.liftweb.mapper.Like
                    
23import com.mongodb.casbah.commons.MongoDBObject
                    
24import java.util.regex.Pattern
                    
37
                    
38  val user = User.findCurrentUser
                    
39
                    
39
                    
40  override def count = Reminder.findAllNotes(
                    
41    user.userIdAsString).size
                    
44
                    
45  override def page = Reminder.findAllNotes(user.userIdAsString,
                    
46    sortOrder,
                    
131    val pattern = Pattern.compile("^" + current, Pattern.CASE_INSENSITIVE)
                    
132    User.findAll(MongoDBObject("name" -> pattern)).map {
                    
133      _.name.is
                    
                
Libraries.scala git://github.com/softprops/ls-server.git | Scala | 196 lines
                    
10  import com.mongodb.casbah.commons.Imports.ObjectId
                    
11  import com.mongodb.casbah.commons.{ MongoDBObject => Obj, MongoDBList => ObjList }
                    
12  import com.mongodb.casbah.{ MongoCollection }
                    
25      log.info("getting libraries for author %s" format ghuser)
                    
26      f(cct(c.find(
                    
27        $or("ghuser" -> anycase(ghuser), "contributors.login" -> anycase(ghuser))
                    
36     log.info("getting libraries for terms %s" format terms.mkString(", "))
                    
37     val possiblies =  (MongoDBObject().empty /: terms)(
                    
38       (a, e) => a += ("name" -> anycase(e))
                    
42     log.info("any query: %s" format query)
                    
43     f(cct( paginate(c.find(query), page, lim).sort(Obj("updated" -> -1)) ))
                    
44   }
                    
50      log.info("getting libraries (page: %s, lim: %s)" format(page, lim))
                    
51      f(cct( paginate(c.find(), page, lim).sort(Obj("updated" -> -1)) ))
                    
52    }
                    
                
ReminderTest.scala https://bitbucket.org/ta_jim/lift_userlogin_template.git | Scala | 185 lines
                    
95      Reminder.createReminder(user.id.toString, "Have to play cricket in morning", "03/12/2013")
                    
96      val reminder = Reminder.find(MongoDBObject("description" -> "Have to play cricket in morning"))
                    
97      val validate = Reminder.deleteReminder(reminder.open_!)
                    
111      Reminder.createReminder(user.id.toString, "Have to play cricket in morning", "03/12/2013")
                    
112      val reminder = Reminder.find(MongoDBObject("description" -> "Have to play cricket in morning"))
                    
113      val validate = Reminder.updateReminder(reminder.open_!, "Have to play cricket in morning", "03/12/2013")
                    
123      Reminder.createReminder(user.id.toString, "Have to play cricket in morning", "03/12/2013")
                    
124      val reminder = Reminder.find(MongoDBObject("description" -> "Have to play cricket in morning"))
                    
125      val validate = Reminder.updateReminder(reminder.open_!, "", "03/12/2013")
                    
135      Reminder.createReminder(user.id.toString, "Have to play cricket in morning", "03/12/2013")
                    
136      val reminder = Reminder.find(MongoDBObject("description" -> "Have to play cricket in morning"))
                    
137      val validate = Reminder.updateReminder(reminder.open_!, "Have to play cricket in morning", "")
                    
147      Reminder.createReminder(user.id.toString, "Have to play cricket in morning", "03/12/2013")
                    
148      val reminder = Reminder.find(MongoDBObject("description" -> "Have to play cricket in morning"))
                    
149      val validate = Reminder.updateReminder(reminder.open_!, "", "")
                    
                
MongoRepositoryTest.scala http://tratata.googlecode.com/svn/trunk/ | Scala | 64 lines
                    
1package com.minosiants.dann.repository

                    
2import com.mongodb.casbah.commons.MongoDBObject
                    
3import org.junit.Assert._
                    
24	@Test
                    
25	def find(){
                    
26		val status=createStatus();
                    
26		val status=createStatus();
                    
27		val result=doFind(Map("id_str"->status.idStr),status)
                    
28		assertTrue(result.size>0)
                    
31	@Test
                    
32	def find_No_result(){
                    
33		val status=createStatus();
                    
33		val status=createStatus();
                    
34		val result=doFind(Map("id_str"->"lala"),status)
                    
35		assertTrue(result.size==0)	
                    
                
MongoResponseRepositoryTest.scala https://github.com/cyrusinnovation/inquisition.git | Scala | 113 lines
                    
12import org.scalatest.junit.JUnitRunner
                    
13import com.mongodb.casbah.commons.MongoDBObject
                    
14import com.mongodb.casbah.commons.MongoDBObject._
                    
25    override def beforeEach() {
                    
26        db("questions").remove(MongoDBObject())
                    
27    }
                    
37
                    
38        val updatedQuestion = questionRepository.findById(savedQuestion.id.get).get
                    
39        val savedResponse = updatedQuestion.responses.head;
                    
50
                    
51        questionRepository.findQuestionCount() should equal(1)
                    
52    }
                    
59
                    
60        val retrievedQuestion = questionRepository.findById(question.id.get)
                    
61        val answers = retrievedQuestion.get.responses
                    
                
CoreWrappersSpec.scala git://github.com/mongodb/casbah.git | Scala | 457 lines
                    
136      collection.insert(MongoDBObject("foo" -> "bar"))
                    
137      val basicFind = collection.find(MongoDBObject("foo" -> "bar"))
                    
138
                    
140
                    
141      val findOne = collection.findOne()
                    
142
                    
144
                    
145      val findOneMatch = collection.findOne(MongoDBObject("foo" -> "bar"))
                    
146
                    
417      // when
                    
418      val findAndModify = Try(collection.findAndModify(MongoDBObject("{x: 10}"), MongoDBObject("{$inc: {x: 1000}}")))
                    
419
                    
423      // when
                    
424      val findAndModifyWithBypass = Try(collection.findAndModify(MongoDBObject("{x: 10}"), MongoDBObject("{}"),
                    
425        MongoDBObject("{}"), false, MongoDBObject("{$inc: {x: 100}}"), true, false, true, Duration(10, "seconds")))
                    
                
User.scala https://github.com/Bochenski/stackcanon.git | Scala | 246 lines
                    
113
                    
114  def login(username: String, password: String) = findOneBy(MongoDBObject("username" -> username.toLowerCase, "password" -> Codec.hexMD5(password)))
                    
115
                    
115
                    
116  def findByUsername(username: String) = findOneBy("username", username.toLowerCase)
                    
117
                    
117
                    
118  def findByGoogleOpenID(id: String) = findOneBy("google_open_id", id)
                    
119
                    
119
                    
120  def findByFacebookID(id: String) = findOneBy("facebook_id", id)
                    
121
                    
164  def getUsersInRole(role: String) =  {
                    
165    findManyByMatchingArrayContent("roles", MongoDBObject(role -> 1))
                    
166  }
                    
                
MongoHelper.scala http://scaly.googlecode.com/svn/trunk/ | Scala | 292 lines
                    
34import com.mongodb.casbah.MongoConnection
                    
35import com.mongodb.casbah.commons.MongoDBObject
                    
36import scala.actors._
                    
66      // Retrieve the portfolio 
                    
67      val portfsQuery = MongoDBObject("id" -> lottery)
                    
68      
                    
68      
                    
69      val portfsCursor = portfsCollecton.find(portfsQuery)
                    
70      
                    
78        // Get the bond from the bond collection
                    
79        val bondQuery = MongoDBObject("id" -> id)
                    
80
                    
80
                    
81        val bondCursor: MongoCursor = bondsCollection.find(bondQuery)
                    
82
                    
                
casbah_iteration_example.scala https://github.com/bwmcadams/presentations.git | Scala | 28 lines
                    
1val mongoColl = MongoConnection()("casbah_test")("test_data")
                    
2val user1 = MongoDBObject("user" -> "bwmcadams",
                    
3                          "email" -> "~~bmcadams~~<AT>novusDOTcom")
                    
3                          "email" -> "~~bmcadams~~<AT>novusDOTcom")
                    
4val user2 = MongoDBObject("user" -> "someOtherUser")
                    
5mongoColl += user1
                    
6mongoColl += user2
                    
7mongoColl.find()
                    
8// com.novus.casbah.mongodb.MongoCursor =
                    
19 
                    
20mongoColl.findOne(q).foreach { x =>
                    
21   // do some work if you found the user...
                    
25// Or limit the fields returned
                    
26val q  = MongoDBObject.empty
                    
27val fields = MongoDBObject("user" -> 1)
                    
                
MongoUserRepository.scala https://github.com/cyrusinnovation/inquisition.git | Scala | 74 lines
                    
20    try {
                    
21      users.update(MongoDBObject("_id" -> user.id), grater[User].asDBObject(user.user), false, false, WriteConcern.Safe)
                    
22    } catch {
                    
32    try {
                    
33      users.insert(MongoDBObject("_id" -> newId) ++ dbObject, WriteConcern.Safe)
                    
34    } catch {
                    
41
                    
42  def findById(id: String): Option[SavedUser] = {
                    
43    val lowerCaseId = id.toLowerCase
                    
44    val query = MongoDBObject("_id" -> lowerCaseId)
                    
45    users.findOne(query) match {
                    
46      case None => None
                    
55  def findByUsername(username: String) = {
                    
56    users.findOne(MongoDBObject("_id" -> username.toLowerCase)) match {
                    
57      case None => None
                    
                
Reminder.scala https://bitbucket.org/ta_jim/lift_userlogin_template.git | Scala | 120 lines
                    
15import java.text.ParsePosition
                    
16import com.mongodb.casbah.commons.MongoDBObject
                    
17
                    
62
                    
63  def findAllNotes(userId: String) = Reminder.findAll((("owner" -> userId)))
                    
64
                    
64
                    
65  def findAllNotes(userId: String, sortOrder: Int, limit: Int, skip: Int) =
                    
66    {
                    
67      sortOrder match {
                    
68        case 0 => Reminder.findAll((("owner" -> userId)), ("created" -> -1), Skip(skip), Limit(limit))
                    
69        case _ => Reminder.findAll((("owner" -> userId)), ("dob" -> sortOrder), Skip(skip), Limit(limit))
                    
116    val end_date = new Date(new Date().getYear(), new Date().getMonth(), new Date().getDate() + 1)
                    
117    Reminder.findAll(MongoDBObject("dob" -> MongoDBObject("$gte" -> start_date, "$lt" -> end_date), "owner" -> new ObjectId(userID)))
                    
118  }
                    
                
SlugMapping.scala https://gitlab.com/guodman/webcbv | Scala | 67 lines
                    
14  def save = {
                    
15    var builder = MongoDBObject.newBuilder
                    
16    builder += "_id" -> _id
                    
43  def getByKey(key: String): SlugMapping = {
                    
44    val r = dbCollection.findOne(MongoDBObject("key" -> key))
                    
45    return r.map(factory).orNull
                    
48  def getByPath(path: String): SlugMapping = {
                    
49    val r = dbCollection.findOne(MongoDBObject("path" -> path))
                    
50    return r.map(factory).orNull
                    
                
$actor_name$.scala https://github.com/itam/scala_akka_mongo.g8.git | Scala | 43 lines
                    
4import com.mongodb.casbah.Imports._
                    
5import com.mongodb.casbah.commons.MongoDBObject
                    
6import akka.actor.Actor._
                    
32        println("POSTing some random text.")
                    
33        collection.insert(MongoDBObject("randomText" -> "POSTING some random text"))
                    
34      }
                    
35      case f: Fetch[ObjectId] => {
                    
36        val dbo = collection.findOne(MongoDBObject("_id" -> f.value))
                    
37
                    
                
DAOTest.scala git://github.com/havocp/mongo-scala-thingy.git | Scala | 80 lines
                    
1import com.mongodb.casbah.commons.MongoDBObject
                    
2import com.mongodb.casbah.MongoCollection
                    
19        def customQuery[E : Manifest]() = {
                    
20            syncDAO[E].find(BObject("intField" -> 23))
                    
21        }
                    
31        def customQuery[E : Manifest]() = {
                    
32            syncDAO[E].find(BObject("intField" -> 23))
                    
33        }
                    
41    def setup() {
                    
42        MongoUtil.collection("foo").remove(MongoDBObject())
                    
43        MongoUtil.collection("fooWithIntId").remove(MongoDBObject())
                    
46    @Test
                    
47    def testSaveAndFindOneCaseClass() {
                    
48        val foo = Foo(new ObjectId(), 23, "woohoo")
                    
49        Foo.caseClassSyncDAO.save(foo)
                    
50        val maybeFound = Foo.caseClassSyncDAO.findOneByID(foo._id)
                    
51        assertTrue(maybeFound.isDefined)
                    
                
Mr06.scala http://scaly.googlecode.com/svn/trunk/ | Scala | 175 lines
                    
33import com.mongodb.casbah.MongoConnection
                    
34import com.mongodb.casbah.commons.MongoDBObject
                    
35import com.mongodb.casbah.MongoCursor
                    
146    
                    
147    val portfsQuery = MongoDBObject("id" -> portfId)
                    
148
                    
148
                    
149    val portfsCursor : MongoCursor = portfsCollecton.find(portfsQuery)
                    
150    
                    
154    
                    
155    val entry = MongoDBObject("id" -> portfId, "instruments" -> ids, "value" -> price)
                    
156    
                    
                
MetadataCache.scala https://github.com/delving/culture-hub.git | Scala | 124 lines
                    
73  def saveOrUpdate(item: MetadataItem) {
                    
74    val mappings = item.xml.foldLeft(MongoDBObject()) { (r, c) => r + (c._1 -> c._2) }
                    
75    val schemaVersions = item.schemaVersions.foldLeft(MongoDBObject()) { (r, c) => r + (c._1 -> c._2) }
                    
76    update(
                    
77      q = MongoDBObject("collection" -> item.collection, "itemType" -> item.itemType, "itemId" -> item.itemId),
                    
78      o = $set(
                    
102
                    
103    val cursor = find(q).sort(MongoDBObject("index" -> 1))
                    
104    if (limit.isDefined) {
                    
116
                    
117  def findOne(itemId: String): Option[MetadataItem] = findOne(MongoDBObject("collection" -> col, "itemType" -> itemType, "itemId" -> itemId))
                    
118
                    
118
                    
119  def findMany(itemIds: Seq[String]): Seq[MetadataItem] = find(MongoDBObject("collection" -> col, "itemType" -> itemType) ++ ("itemId" $in itemIds)).toSeq
                    
120
                    
                
Role.scala https://github.com/Bochenski/stackcanon.git | Scala | 77 lines
                    
33  def create(name: String) = {
                    
34    val builder = MongoDBObject.newBuilder
                    
35    builder += "name" -> name
                    
41  def destroy(id: String) = {
                    
42    remove(MongoDBObject("_id" -> new ObjectId(id)))
                    
43  }
                    
48
                    
49  def findByName(name: String) = {
                    
50    findOneBy("name", name)
                    
65  private def CreateRoleIfMissing(role: String) = {
                    
66     findByName(role) match {
                    
67      case None => {
                    
68        create(role)
                    
69        var newRole = findByName(role)
                    
70        newRole.get.getIdString
                    
                
Par00.scala http://scaly.googlecode.com/svn/trunk/ | Scala | 178 lines
                    
33import com.mongodb.casbah.MongoConnection
                    
34import com.mongodb.casbah.commons.MongoDBObject
                    
35import com.mongodb.casbah.MongoCursor
                    
142    
                    
143    val portfsQuery = MongoDBObject("id" -> portfId)
                    
144
                    
144
                    
145    val portfsCursor : MongoCursor = portfsCollecton.find(portfsQuery)
                    
146    
                    
155      // Get the bond from the bond collection by its key id
                    
156      val bondQuery = MongoDBObject("id" -> id)
                    
157
                    
157
                    
158      val bondCursor: MongoCursor = bondsCollection.find(bondQuery)
                    
159
                    
                
MongoWriter.scala https://github.com/tackley/travel-map.git | Scala | 27 lines
                    
3import com.mongodb.casbah.Imports._
                    
4import com.mongodb.casbah.commons.MongoDBObject
                    
5import org.joda.time.DateTime
                    
14  def mostRecentLastModified = {
                    
15    ContentItem.find(MongoDBObject())
                    
16      .sort(orderBy = MongoDBObject("lastModified" -> -1))
                    
                
MongoCollection.scala git://github.com/mongodb/casbah.git | Scala | 1208 lines
                    
163   */
                    
164  def find(): CursorType = _newCursor(underlying.find)
                    
165
                    
170   */
                    
171  def find[A <% DBObject](ref: A): CursorType = _newCursor(underlying.find(ref))
                    
172
                    
194   */
                    
195  def find[A <% DBObject, B <% DBObject](ref: A, keys: B): CursorType = _newCursor(underlying.find(ref, keys))
                    
196
                    
214   */
                    
215  def findOne(): Option[T] = _typedValue(underlying.findOne())
                    
216
                    
251   */
                    
252  def findOneByID(id: AnyRef): Option[T] = _typedValue(underlying.findOne(id))
                    
253
                    
                
MuddlApp.scala https://github.com/jorgeortiz85/muddl-sample.git | Scala | 36 lines
                    
21    // which blow up on deserialization, so we'll avoid them
                    
22    val nonEmptyVenues = MongoDBObject("userid" -> MongoDBObject("$exists" -> true))
                    
23
                    
24    val venues: Seq[NiceVenue] = databases.venues.find(nonEmptyVenues, 10)
                    
25    val checkins: Seq[Checkin] = databases.checkins.find(MongoDBObject(), 10)
                    
26
                    
                
QueryIntegrationSpec.scala git://github.com/mongodb/casbah.git | Scala | 519 lines
                    
52      collection.update(MongoDBObject("foo" -> "baz"), set)
                    
53      collection.find(MongoDBObject("foo" -> "bar")).count must beEqualTo(1)
                    
54    }
                    
63        collection.update(MongoDBObject(), $setOnInsert("foo" -> "baz"), upsert = true)
                    
64        collection.find(MongoDBObject("foo" -> "baz")).count must beEqualTo(1)
                    
65      } catch {
                    
78        collection.update(MongoDBObject(), set, upsert = true)
                    
79        collection.find(MongoDBObject("foo" -> "baz")).count must beEqualTo(1)
                    
80      } catch {
                    
93        collection.find(MongoDBObject("x" -> 1)).count must beEqualTo(1)
                    
94        collection.find(MongoDBObject("a" -> "b")).count must beEqualTo(1)
                    
95      } catch {
                    
370          collection.update(MongoDBObject("_id" -> "xyz"), pull)
                    
371          collection.findOne().get.as[MongoDBList]("answers") must beEqualTo(MongoDBList(MongoDBObject("name" -> "No")))
                    
372        }
                    
                
BulkWriteOperationSpec.scala git://github.com/mongodb/casbah.git | Scala | 406 lines
                    
292      collection.findOne(MongoDBObject("_id" -> 7)) must beSome(MongoDBObject("_id" -> 7))
                    
293      collection.findOne(MongoDBObject("_id" -> 8)) must beSome(MongoDBObject("_id" -> 8))
                    
294    }
                    
335      collection.findOne(MongoDBObject("_id" -> 1)) must beSome(MongoDBObject("_id" -> 1, "x" -> 2))
                    
336      collection.findOne(MongoDBObject("_id" -> 2)) must beSome(MongoDBObject("_id" -> 2, "x" -> 3))
                    
337      collection.findOne(MongoDBObject("_id" -> 3)) must beNone
                    
338      collection.findOne(MongoDBObject("_id" -> 4)) must beNone
                    
339      collection.findOne(MongoDBObject("_id" -> 5)) must beSome(MongoDBObject("_id" -> 5, "x" -> 4))
                    
340      collection.findOne(MongoDBObject("_id" -> 6)) must beSome(MongoDBObject("_id" -> 6, "x" -> 5))
                    
340      collection.findOne(MongoDBObject("_id" -> 6)) must beSome(MongoDBObject("_id" -> 6, "x" -> 5))
                    
341      collection.findOne(MongoDBObject("_id" -> 7)) must beSome(MongoDBObject("_id" -> 7))
                    
342      collection.findOne(MongoDBObject("_id" -> 8)) must beSome(MongoDBObject("_id" -> 8))
                    
350      operation.insert(MongoDBObject("_id" -> 1))
                    
351      operation.find(MongoDBObject("_id" -> 2)).updateOne(MongoDBObject("$set" -> MongoDBObject("x" -> 3)))
                    
352      operation.insert(MongoDBObject("_id" -> 3))
                    
                
KmlGenerator.scala https://github.com/tackley/travel-map.git | Scala | 41 lines
                    
3import loader.ContentItem
                    
4import com.mongodb.casbah.commons.MongoDBObject
                    
5import xml.{NodeSeq, Unparsed}
                    
17          for {
                    
18            c <- ContentItem.find(MongoDBObject())
                    
19            lat <- c.lat
                    
                
test.scala git://github.com/ochafik/Scalaxy.git | Scala | 91 lines
                    
81    val dict = MongoConnection("localhost")("appdb")("dict")
                    
82    val index = MongoDBObject("_id" -> "_index")
                    
83    dict.update(index, makeEntry("applaud"), true, false)
                    
87
                    
88    val entry = dict.findOne(index ++ ("a.p.p" $exists true))
                    
89    println(entry)
                    
                
Mr04.scala http://scaly.googlecode.com/svn/trunk/ | Scala | 204 lines
                    
33import com.mongodb.casbah.MongoConnection
                    
34import com.mongodb.casbah.commons.MongoDBObject
                    
35import com.mongodb.casbah.MongoCursor
                    
91      // Retrieve the portfolio 
                    
92      val portfsQuery = MongoDBObject("id" -> r)
                    
93
                    
93
                    
94      val portfsCursor: MongoCursor = portfsCollecton.find(portfsQuery)
                    
95
                    
173    
                    
174    val bondQuery = MongoDBObject("id" -> bondId)
                    
175
                    
175
                    
176    val bondCursor: MongoCursor = bondsCollection.find(bondQuery)
                    
177
                    
                
ConversionsSpec.scala git://github.com/mongodb/casbah.git | Scala | 328 lines
                    
49
                    
50      collection += MongoDBObject("some" -> Some("foo"), "none" -> None)
                    
51
                    
51
                    
52      val optDoc = collection.findOne().getOrElse(
                    
53        throw new IllegalArgumentException("No document")
                    
69      lazy val saveDate = {
                    
70        collection += MongoDBObject("date" -> jodaDate, "type" -> "joda")
                    
71      }
                    
74
                    
75      collection += MongoDBObject("date" -> jdkDate, "type" -> "jdk")
                    
76
                    
76
                    
77      val jdkEntry = collection.findOne(
                    
78        MongoDBObject("type" -> "jdk"),
                    
                
NPortfolio00.scala http://scaly.googlecode.com/svn/trunk/ | Scala | 171 lines
                    
28import com.mongodb.casbah.MongoConnection
                    
29import com.mongodb.casbah.commons.MongoDBObject
                    
30import com.mongodb.casbah.MongoCursor
                    
92      
                    
93      val portfsQuery = MongoDBObject("id" -> portfId)
                    
94
                    
94
                    
95      val portfsCursor: MongoCursor = portfsCollecton.find(portfsQuery)
                    
96
                    
105        // Get the bond from the bond collection
                    
106        val bondQuery = MongoDBObject("id" -> id)
                    
107
                    
107
                    
108        val bondCursor: MongoCursor = bondsCollection.find(bondQuery)
                    
109
                    
                
PrefixIndexer.scala https://gitlab.com/18runt88/twofishes | Scala | 148 lines
                    
76  def getRecordsByPrefix(prefix: String, limit: Int) = {
                    
77    val nameCursor = NameIndexDAO.find(
                    
78      MongoDBObject(
                    
80        "excludeFromPrefixIndex" -> false)
                    
81    ).sort(orderBy = MongoDBObject("pop" -> -1)).limit(limit)
                    
82    nameCursor.option = Bytes.QUERYOPTION_NOTIMEOUT
                    
82    nameCursor.option = Bytes.QUERYOPTION_NOTIMEOUT
                    
83    val prefixCursor = NameIndexDAO.find(
                    
84      MongoDBObject(
                    
84      MongoDBObject(
                    
85        "name" -> MongoDBObject("$regex" -> "^%s".format(prefix)),
                    
86        "excludeFromPrefixIndex" -> false)
                    
86        "excludeFromPrefixIndex" -> false)
                    
87    ).sort(orderBy = MongoDBObject("pop" -> -1)).limit(limit)
                    
88    prefixCursor.option = Bytes.QUERYOPTION_NOTIMEOUT
                    
                
OpLog.scala git://github.com/mongodb/casbah.git | Scala | 199 lines
                    
62  // scalastyle:off public.methods.have.type
                    
63  val cursor = oplog.find(q)
                    
64  cursor.option = Bytes.QUERYOPTION_TAILABLE
                    
76    // Verify the oplog exists
                    
77    val last = oplog.find().sort(MongoDBObject("$natural" -> 1)).limit(1)
                    
78    assume(
                    
89      case Some(ts) => {
                    
90        oplog.findOne(MongoDBObject("ts" -> ts)).orElse(
                    
91          throw new Exception("No oplog entry for requested start timestamp.")
                    
102  // scalastyle:off public.methods.have.type
                    
103  def apply(entry: MongoDBObject) = entry("op") match {
                    
104    case InsertOp.typeCode =>
                    
186case class MongoUpdateOperation(timestamp: BSONTimestamp, opID: Option[Long], namespace: String,
                    
187                                document: MongoDBObject, documentID: MongoDBObject) extends MongoOpLogEntry {
                    
188  val opType = UpdateOp
                    
                
DefRepo.scala git://github.com/ornicar/scalex.git | Scala | 32 lines
                    
16  def byIds(ids: Seq[String]): List[Def] = {
                    
17    val defs = find("_id" $in ids) toList
                    
18    val sorted = ids map { id => defs.find(_.id == id) }
                    
22  def removePack(pack: String) {
                    
23    collection remove MongoDBObject("pack" -> pack)
                    
24  }
                    
25
                    
26  def findAll: List[Def] = find(MongoDBObject()).toList
                    
27
                    
27
                    
28  def findByDeclaration(dec: String) = findOne(MongoDBObject(
                    
29    "declaration" -> dec
                    
                
LazyDecodingSpec.scala git://github.com/mongodb/casbah.git | Scala | 191 lines
                    
40      coll must haveClass[LazyMongoCollection]
                    
41      coll.find() must haveClass[LazyMongoCursor]
                    
42      coll.find().next() must haveClass[OptimizedLazyDBObject]
                    
70      def runSum(c: MongoCollection) =
                    
71        c.find().map(doc => fetchBook(doc)).sum
                    
72
                    
98      val testOid = new ObjectId
                    
99      val testRefOid = mongoInt("books").findOne().get.getAs[ObjectId]("_id")
                    
100      val testDoc = MongoDBObject("abc" -> "12345")
                    
107      val testRE = "^test.*regex.*xyz$".r
                    
108      val inDoc = MongoDBObject("_id" -> oid ,
                    
109                                "null" -> null ,
                    
144        coll += inDoc
                    
145        coll.findOne(MongoDBObject("_id" -> oid)) match {
                    
146          case None =>
                    
                
ReadResource.scala http://sample-scala.googlecode.com/svn/trunk/ | Scala | 48 lines
                    
4import org.steve.utils.CommonConversions._
                    
5import com.mongodb.casbah.commons.MongoDBObject
                    
6
                    
9  get("/") {
                    
10    val names = PersonDAO.find(MongoDBObject()) map { _.name }
                    
11    <html>
                    
26    val id = params("id")
                    
27    PersonDAO.findOneByID(id.toObjectId).toJson
                    
28  }
                    
                
ApplicationSetting.scala https://github.com/Bochenski/stackcanon.git | Scala | 77 lines
                    
22
                    
23  def findByKey(key: String) = findOneBy("key", key)
                    
24
                    
28    //check whether the user exists
                    
29    val setting = findByKey(key)
                    
30    setting match {
                    
32      case None => {
                    
33        val builder = MongoDBObject.newBuilder
                    
34        builder += "key" -> key
                    
44  def update(key: String, value: String): Boolean = {
                    
45    val setting = findByKey(key)
                    
46    setting match {
                    
51      case Some(_) => {
                    
52        ApplicationSetting.update(MongoDBObject("_id" -> setting.get.oid.get), $set("value" -> value))
                    
53        if (settings.contains(key)) {
                    
                
FileManager.scala https://github.com/Bochenski/stackcanon.git | Scala | 75 lines
                    
28          fh.contentType = "image/" + extension.get.toString
                    
29          fh.metaData = MongoDBObject("parentType" -> parentType, "parentId" -> parentId, "sequence" -> sequence)
                    
30     }
                    
52  def getFile(parentType: String, parentId: String, sequence: Int): Option[GridFSDBFile] = {
                    
53    MongoDB.getGridFS.findOne(MongoDBObject("metadata.parentType" -> parentType, "metadata.parentId" -> parentId, "metadata.sequence" -> sequence))
                    
54  }
                    
56  def getFileCount(parentType: String, parentId: String) = {
                    
57    val count = MongoDB.getDB("fs.files").count(MongoDBObject("metadata.parentType" -> parentType, "metadata.parentId" -> parentId))
                    
58    Logger.info("found " + count.toString + " files")
                    
71
                    
72    MongoDB.getGridFS.remove(MongoDBObject("metadata.parentType" -> parentType, "metadata.parentId" -> parentId, "metadata.sequence" -> sequence))
                    
73  }
                    
                
MongoTest.scala git://github.com/btarbox/Log4ScalaFugue.git | Scala | 69 lines
                    
44    loadSomeData(mongo)
                    
45    find(mongo)
                    
46  }
                    
48  def removeOldData(mongo: MongoDataGetter) = {
                    
49    for ( x <- mongo.conn.find()) {
                    
50     mongo.conn.remove(x)
                    
55    for(x <- 1 to 20) {
                    
56    val newObj = MongoDBObject("timestamp" -> x.toString,
                    
57                               "category"  -> "general",
                    
63  def find(mongo: MongoDataGetter) = {
                    
64    for { x <- mongo.conn.find().sort(MongoDBObject("timeColumn" -> "1")); thisTime = x.get("timestamp"); if(thisTime != null)} {
                    
65      println(x)
                    
                
DataSetEventLog.scala https://github.com/delving/culture-hub.git | Scala | 52 lines
                    
26  def initIndexes(collection: MongoCollection) {
                    
27    addIndexes(collection, Seq(MongoDBObject("orgId" -> 1)))
                    
28    addIndexes(collection, Seq(MongoDBObject("transientEvent" -> 1)))
                    
36  def findRecent = {
                    
37    val nonTransient = find(MongoDBObject("transientEvent" -> false)).limit(10).sort(MongoDBObject("_id" -> -1)).toList
                    
38    val transient = find(MongoDBObject("transientEvent" -> true)).limit(40).sort(MongoDBObject("_id" -> -1)).toList
                    
43  def removeTransient() {
                    
44    val recent = find(MongoDBObject("transientEvent" -> true)).limit(10).sort(MongoDBObject("_id" -> -1)).toList.reverse.headOption
                    
45    recent.map { r =>
                    
45    recent.map { r =>
                    
46      remove(MongoDBObject("transientEvent" -> true) ++ ("_id" $lt r._id))
                    
47    }.getOrElse {
                    
47    }.getOrElse {
                    
48      remove(MongoDBObject("transientEvent" -> true))
                    
49    }
                    
                
Version.scala https://github.com/Bochenski/stackcanon.git | Scala | 119 lines
                    
26  def create(version: Int) = {
                    
27    val builder = MongoDBObject.newBuilder
                    
28    builder += "version" -> version
                    
34  def check() = {
                    
35    //first find our current DB version
                    
36    Logger.info("checking DB version and updating if required)")
                    
38    Logger.info("appVersion " + appVersion.toString)
                    
39    findOne match {
                    
40      case Some(entry) => {
                    
69              user.getUserRoleIdStrings foreach { role =>
                    
70                models.Role.findByName(role)  match {
                    
71                  case Some(dbRole) => {
                    
76                    models.Role.create(role)
                    
77                    val dbRole = models.Role.findByName(role).get
                    
78                    currentRoles = migrateRoleNamesToRoleIds(user,role,dbRole,currentRoles)
                    
                
ContentEntry.scala https://bitbucket.org/wbillingsley/ibmongo-2012-old-version-duct-tape-not-maintained.git | Scala | 250 lines
                    
109     */
                    
110    val u = MongoDBObject("$set" -> MongoDBObject(
                    
111       "book" -> ce._book, "addedBy" -> ce._addedBy,  
                    
137      case Some(bid) => {
                    
138        val cursor = sdao.find(MongoDBObject("book" -> bid, "topics" -> topic, "inTrash" -> false)) // TODO check whether we need a $in
                    
139        cursor.toSeq
                    
222      EntryCommentDAO.save(c)      
                    
223      val update = MongoDBObject("$inc" -> MongoDBObject("ncomments" -> 1))
                    
224      val query = MongoDBObject("_id" -> entry.id)
                    
233      val dbV = grater[Vote].asDBObject(v)            
                    
234      val update = MongoDBObject("$push" -> MongoDBObject("votes" -> dbV), "$inc" -> MongoDBObject("nvotes" -> 1, "score" -> 1))
                    
235      val query = MongoDBObject("_id" -> ceId, "votes.addedBy" -> MongoDBObject("$ne" -> rId))
                    
243      val dbV = grater[Vote].asDBObject(v)            
                    
244      val update = MongoDBObject("$push" -> MongoDBObject("votes" -> dbV), "$inc" -> MongoDBObject("nvotes" -> 1, "score" -> -1))
                    
245      val query = MongoDBObject("_id" -> ceId, "votes.addedBy" -> MongoDBObject("$ne" -> rId))
                    
                
OnePortfolio00.scala http://scaly.googlecode.com/svn/trunk/ | Scala | 96 lines
                    
36import com.mongodb.casbah.MongoConnection
                    
37import com.mongodb.casbah.commons.MongoDBObject
                    
38import com.mongodb.BasicDBList
                    
57    
                    
58    val portfsQuery = MongoDBObject("id" -> 1)
                    
59
                    
59
                    
60    val portfsCursor : MongoCursor = portfsCollecton.find(portfsQuery)
                    
61    
                    
68    val value = bondIds.foldLeft(0.0) { (sum, id) =>
                    
69      val bondsQuery = MongoDBObject("id" -> id)
                    
70
                    
70
                    
71      val bondsCursor: MongoCursor = bondsCollection.find(bondsQuery)
                    
72
                    
                
ArchiveRepository.scala https://github.com/kufi/Filefarmer.git | Scala | 64 lines
                    
3import ch.filefarmer.database.connection.IConnection
                    
4import com.mongodb.casbah.commons.MongoDBObject
                    
5import ch.filefarmer.poso._
                    
14	def getArchive(identity:String) = {
                    
15		val search = MongoDBObject("identity" -> identity)
                    
16		
                    
16		
                    
17		archiveConnection.findOne(search) match {
                    
18		  case Some(ret) => {
                    
46	def getArchiveTree(parent:String = ""): Option[ArchiveTree] = {
                    
47		var search = MongoDBObject("parentArchiveId" -> parent)
                    
48		
                    
50		
                    
51		val results = archiveConnection.find(search)
                    
52		
                    
                
SalatExamples.scala https://bitbucket.org/Tolsi/scala-school-2018-2.git | Scala | 39 lines
                    
16
                    
17  val entity: Option[Entity] = dao.findOneById("333")
                    
18
                    
18
                    
19  val queryResult: SalatMongoCursor[Entity] = dao.find(MongoDBObject("params.x" -> 15))
                    
20
                    
32
                    
33  val removeByQueryResult = dao.remove(MongoDBObject("_id" -> "5"))
                    
34
                    
36
                    
37  val updateResult: WriteResult = dao.update(MongoDBObject("_id" -> "4"), $set("params.x" -> 18), upsert = false)
                    
38
                    
                
Article.scala https://github.com/ngocdaothanh/tivua.git | Scala | 125 lines
                    
60
                    
61    val cur = articleColl.find().sort(MongoDBObject("sticky" -> -1, "thread_updated_at" -> -1)).skip((p - 1) * ITEMS_PER_PAGE).limit(ITEMS_PER_PAGE)
                    
62    val buffer = ArrayBuffer[Article]()
                    
82
                    
83  def first(id: String): Option[Article] = articleColl.findOneByID(new ObjectId(id)).map(mongoToScala)
                    
84
                    
85  def categoryPage(categoryId: String, page: Int): (Int, Iterable[Article]) = {
                    
86    val count = articleCategoryColl.count(MongoDBObject("category_id" -> categoryId)).toInt
                    
87    val numPages = (count / ITEMS_PER_PAGE) + (if (count % ITEMS_PER_PAGE == 0) 0 else 1)
                    
88
                    
89    val cur = articleCategoryColl.find(MongoDBObject("category_id" -> categoryId)).sort(MongoDBObject("sticky" -> -1, "thread_updated_at" -> -1)).skip((page - 1) * ITEMS_PER_PAGE).limit(ITEMS_PER_PAGE)
                    
90    val buffer = ArrayBuffer[Article]()
                    
113    val categories = {
                    
114      val cur = articleCategoryColl.find(MongoDBObject("article_id" -> id))
                    
115      val buffer = ArrayBuffer[Category]()
                    
                
Groups.scala https://github.com/delving/culture-hub.git | Scala | 260 lines
                    
49        } else {
                    
50          val group: Option[Group] = groupId.flatMap(Group.dao.findOneById(_))
                    
51          val usersAsTokens = group match {
                    
75      } else {
                    
76        Group.dao.remove(MongoDBObject("_id" -> groupId, "orgId" -> configuration.orgId))
                    
77        Ok
                    
102
                    
103              if (role == Role.OWN && (groupForm.id == None || groupForm.id != None && Group.dao.findOneById(groupForm.id.get) == None)) {
                    
104                reportSecurity("User %s tried to create an owners team!".format(connectedUser))
                    
127
                    
128                  Group.dao.findOneById(groupForm.id.get) match {
                    
129                    case None => return MultitenantAction {
                    
139                            groupForm.resources.flatMap { resourceToken =>
                    
140                              lookup.findResourceByKey(configuration.orgId, resourceToken.id)
                    
141                            }
                    
                
MovieActor.scala https://bitbucket.org/tdrobinson/traktor.git | Scala | 87 lines
                    
9import org.bson.types.ObjectId
                    
10import com.mongodb.casbah.commons.MongoDBObject
                    
11
                    
35  def listAll(implicit dbObject2JObject: DBObject => JValue) =
                    
36    JArray(collection.find().toList.map(db => dbObject2JObject(db)))
                    
37
                    
38  def listAllPending(implicit dbObject2JObject: DBObject => JValue) =
                    
39    JArray(collection.find("results" $exists true).toList.map(db => dbObject2JObject(db)))
                    
40
                    
42    val result = jValue2DBObject(obj)
                    
43    collection.findOneByID(new ObjectId(result.removeField("movie_id").asInstanceOf[String])) match {
                    
44      case Some(movie) =>
                    
68    {
                    
69      val forRemoval = ms.map(m => collection.findOne(MongoDBObject("filename" -> m))).filter(m => {
                    
70        m.isDefined && !m.get.containsField("results")
                    
                
DbObject.scala http://scaly.googlecode.com/svn/trunk/ | Scala | 158 lines
                    
28import com.mongodb.casbah.MongoConnection
                    
29import com.mongodb.casbah.commons.{ MongoDBObject, MongoDBList }
                    
30import scala.io.Source
                    
55
                    
56    // Creating an empty MongoDBObject List  
                    
57    var list = List(MongoDBObject())
                    
69      
                    
70      val entry = MongoDBObject("id" -> id, "coupon" -> details(1).trim.toDouble, "freq" -> details(2).trim.toInt, "tenor" -> details(3).trim.toInt, "maturity" -> details(4).trim.toDouble)
                    
71      
                    
77    // Print the current size of Bond Collection in DB
                    
78    println(mongo.find().size + " documents inserted into collection: "+COLL_BONDS)
                    
79  }
                    
86
                    
87    // Creating an empty MongoDBObject List  
                    
88    var list = List(MongoDBObject())
                    
                
ManageSpecies.scala git://github.com/JanxSpirit/mycotrack_mongo.git | Scala | 169 lines
                    
64      "allSpecies" -> {
                    
65        for (species <- Species.findAll) yield <li>
                    
66          <a href={"speciesInfo/" + species.id.toString}>
                    
122      "image" -> {
                    
123        val photo = MycoMongoDb.gridFs.findOne(MongoDBObject("species_id" -> species.id))
                    
124        photo match {
                    
140
                    
141        val files = MycoMongoDb.gridFs.find(MongoDBObject("species_id" -> species.id)).map(_.get("filename")).distinct
                    
142        println(files)
                    
145          println(fn)
                    
146          val thumbnail_id = MycoMongoDb.gridFs.findOne(MongoDBObject("filename" -> fn, "species_id" -> species.id, "size" -> "thumbnail")).map(_.id).getOrElse("404")
                    
147          val original_id = MycoMongoDb.gridFs.findOne(MongoDBObject("filename" -> fn, "species_id" -> species.id, "size" -> "original")).map(_.id).getOrElse("404")
                    
147          val original_id = MycoMongoDb.gridFs.findOne(MongoDBObject("filename" -> fn, "species_id" -> species.id, "size" -> "original")).map(_.id).getOrElse("404")
                    
148          val display_id = MycoMongoDb.gridFs.findOne(MongoDBObject("filename" -> fn, "species_id" -> species.id, "size" -> "display")).map(_.id).getOrElse("404")
                    
149          val thumbnail_url = "/images/%s" format thumbnail_id
                    
                
FileStorage.scala https://github.com/delving/culture-hub.git | Scala | 186 lines
                    
26  def listFiles(bucketId: String, fileType: Option[String] = None)(implicit configuration: OrganizationConfiguration): List[StoredFile] = {
                    
27    val query = MongoDBObject(ITEM_POINTER_FIELD -> bucketId) ++ fileType.map(t => MongoDBObject(ITEM_TYPE -> t)).getOrElse(MongoDBObject())
                    
28    fileStore(configuration).
                    
28    fileStore(configuration).
                    
29      find(query).
                    
30      map(f => fileToStoredFile(f)).toList
                    
56
                    
57    fileStore(configuration).findOne(f._id.get).map { f =>
                    
58      fileToStoredFile(f)
                    
76        // remove thumbnails
                    
77        fileStore(configuration).find(MongoDBObject(FILE_POINTER_FIELD -> id)) foreach { t =>
                    
78          fileStore(configuration).remove(t.getId.asInstanceOf[ObjectId])
                    
86  def renameBucket(oldBucketId: String, newBucketId: String)(implicit configuration: OrganizationConfiguration) {
                    
87    val files: Seq[com.mongodb.gridfs.GridFSDBFile] = fileStore(configuration).find(MongoDBObject(ITEM_POINTER_FIELD -> oldBucketId))
                    
88    files.foreach { file =>
                    
                
demoMongoDb.scala http://findataweb.googlecode.com/svn/trunk/ | Scala | 167 lines
                    
9// use casbah
                    
10:cp Documents/findataweb/scala/demos/lib/mongo-2.5.1.jar
                    
11:cp Documents/findataweb/scala/demos/lib/casbah-core_2.8.1-2.1.0.jar
                    
11:cp Documents/findataweb/scala/demos/lib/casbah-core_2.8.1-2.1.0.jar
                    
12:cp Documents/findataweb/scala/demos/lib/casbah-commons_2.8.1-2.1.0.jar
                    
13:cp Documents/findataweb/scala/demos/lib/casbah-query_2.8.1-2.1.0.jar
                    
14
                    
15:cp Documents/findataweb/scala/demos/lib/joda-time-1.6.jar
                    
16:cp Documents/findataweb/scala/demos/lib/scalaj-collection_2.8.0-1.0.jar
                    
16:cp Documents/findataweb/scala/demos/lib/scalaj-collection_2.8.0-1.0.jar
                    
17:cp Documents/findataweb/scala/demos/lib/slf4j-api-1.6.1.jar
                    
18:cp Documents/findataweb/scala/demos/lib/slf4j-jdk14-1.6.1.jar
                    
26
                    
27val newObj = MongoDBObject("foo" -> "bar",
                    
28                           "x" -> "y",
                    
                
Domain.scala git://github.com/olim7t/mongo-scala.git | Scala | 74 lines
                    
29
                    
30    def findById(id: ObjectId): Option[Event] = mongoDb("events").findOneByID(id).map(dbToEvent)
                    
31
                    
37
                    
38    def removeById(id: ObjectId) = mongoDb("events").remove(MongoDBObject("_id" -> id))
                    
39
                    
41
                    
42    def countWithName(name: String) = mongoDb("events").count(MongoDBObject("name" -> name))
                    
43
                    
45      val dbObject = sessionToDb(session)
                    
46      mongoDb("events").update(MongoDBObject("_id" -> eventId), $push("sessions" -> dbObject))
                    
47    }
                    
54
                    
55    def findLast10By(town: String, descriptionContains: String) = {
                    
56      val descriptionRegexp = (".*" + descriptionContains + ".*").r
                    
                
ConversionsSpec.scala git://github.com/ymasory/scala-corpus.git | Scala | 180 lines
                    
64      
                    
65      val jdkEntry = mongo.findOne(MongoDBObject("type" -> "jdk"), 
                    
66                                   MongoDBObject("date" -> 1))
                    
84
                    
85      val jodaEntry = mongo.findOne(MongoDBObject("type" -> "joda"), 
                    
86                                    MongoDBObject("date" -> 1))
                    
112      
                    
113      val jdkEntry = mongo.findOne(MongoDBObject("type" -> "jdk"), 
                    
114                                   MongoDBObject("date" -> 1))
                    
132      
                    
133      val jdkEntry = mongo.findOne(MongoDBObject("type" -> "jdk"), 
                    
134                                   MongoDBObject("date" -> 1))
                    
147
                    
148      val jodaEntry = mongo.findOne(MongoDBObject("type" -> "jdk"), 
                    
149                                    MongoDBObject("date" -> 1))
                    
                
FeedBotSpec.scala git://github.com/HendraWijaya/syndor.git | Scala | 77 lines
                    
11import syndor.model.Feed
                    
12import com.mongodb.casbah.commons.MongoDBObject
                    
13import java.text.SimpleDateFormat
                    
58    val title = "Spain, Italy under pressure as EU frames bank deal"
                    
59    val cursor = FeedItem.find(ref = MongoDBObject("title" -> title))
                    
60    val item = cursor.next
                    
                
casbah_dbobject_sample1.scala https://github.com/bwmcadams/presentations.git | Scala | 60 lines
                    
33// "Factory" method
                    
34val constructed: DBObject = MongoDBObject(
                    
35  "foo" -> "bar",
                    
47// We showed the builder before
                    
48val builder = MongoDBObject.newBuilder
                    
49builder += "foo" -> "bar"
                    
58built += "x" -> "y"
                    
59built.getOrElse("x", throw new Error("Can't find value for X")) 
                    
60/* res15: AnyRef = y */
                    
                
MongoStorageBackend.scala https://github.com/yllan/akka.git | Scala | 230 lines
                    
48    db.safely { db =>
                    
49      val q: DBObject = MongoDBObject(KEY -> name)
                    
50      coll.findOne(q) match {
                    
54        case None => 
                    
55          val builder = MongoDBObject.newBuilder
                    
56          builder += KEY -> name
                    
63  def removeMapStorageFor(name: String): Unit = {
                    
64    val q: DBObject = MongoDBObject(KEY -> name)
                    
65    db.safely { db => coll.remove(q) }
                    
68
                    
69  private def queryFor[T](name: String)(body: (MongoDBObject, Option[DBObject]) => T): T = {
                    
70    val q = MongoDBObject(KEY -> name)
                    
70    val q = MongoDBObject(KEY -> name)
                    
71    body(q, coll.findOne(q))
                    
72  }
                    
                
MycotrackUrlRewriter.scala git://github.com/JanxSpirit/mycotrack_mongo.git | Scala | 49 lines
                    
21    ParsePath("projects" :: key :: Nil, "", true, false), _, _) => {
                    
22      val project = Project.find(MongoDBObject("key" -> key))
                    
23      SelectedProject(project)
                    
35    ParsePath("speciesInfo" :: id :: Nil, "", true, false), _, _) => {
                    
36      val species = Species.find(id)
                    
37      theSpecies(species)
                    
42    ParsePath("splitProject" :: id :: Nil, "", true, false), _, _) => {
                    
43      val project = Project.find(id)
                    
44      SelectedProject(project)
                    
                
Task.scala git://github.com/Mironor/Play-2.0-Scala-MongoDb-Salat-exemple.git | Scala | 38 lines
                    
23      .getOrElse(throw new PlayException("Configuration error",
                    
24      "Could not find mongodb.default.db in settings"))
                    
25  )("tasks"))
                    
28object Task {
                    
29    def all(): List[Task] = TaskDAO.find(MongoDBObject.empty).toList
                    
30
                    
35    def delete(id: String) {
                    
36        TaskDAO.remove(MongoDBObject("_id" -> new ObjectId(id)))
                    
37    }
                    
                
g8.scala git://github.com/softprops/ls-server.git | Scala | 143 lines
                    
4  import com.mongodb.casbah.commons.Imports.ObjectId
                    
5  import com.mongodb.casbah.commons.{MongoDBObject => Obj, MongoDBList => ObjList}
                    
6  import com.mongodb.casbah.{MongoCollection, MongoCursor}
                    
28  import com.mongodb.casbah.commons.Imports.ObjectId
                    
29  import com.mongodb.casbah.commons.{ MongoDBObject => Obj, MongoDBList => ObjList }
                    
30  import com.mongodb.casbah.{ MongoCollection }
                    
52      log.info("getting templates (page: %s, limit: %s)" format(page, limit))
                    
53      f(cct(paginate(c.find(), page, limit).sort(
                    
54        Obj("username" -> 1, "name"-> 1))))
                    
78          f(cct(
                    
79            paginate(c.find(q), page, limit).sort(
                    
80               Obj("username" -> 1, "name"-> 1))
                    
93      log.info("create or update selection query %s" format query)
                    
94      col.findAndModify(
                    
95        query, // query
                    
                
PlainCasbah.scala git://github.com/havocp/beaucatcher.git | Scala | 96 lines
                    
40
                    
41    private def convertObject(obj : Map[String, Any]) : MongoDBObject = {
                    
42        val builder = MongoDBObject.newBuilder
                    
62
                    
63    override def findOne(collection : MongoCollection) = {
                    
64        val maybeOne = collection.findOne()
                    
68
                    
69    override def findAll(collection : MongoCollection, numberExpected : Int) = {
                    
70        val all = collection.find()
                    
80
                    
81    override def findAllAsync(collection : MongoCollection, numberExpected : Int) : BenchmarkFuture = {
                    
82        BenchmarkFuture(threads.submit(new Runnable() {
                    
83            override def run() = {
                    
84                findAll(collection, numberExpected)
                    
85            }
                    
                
ManageProject.scala git://github.com/JanxSpirit/mycotrack_mongo.git | Scala | 62 lines
                    
3import xml.NodeSeq
                    
4import com.mongodb.casbah.commons.MongoDBObject
                    
5import _root_.net.liftweb.util.Helpers
                    
8import Helpers._
                    
9import net.liftweb.http.{RequestVar, S, TemplateFinder, SHtml}
                    
10import com.mycotrack.model.{Species, Project, User}
                    
27      "image" -> {
                    
28        val photo = MycoMongoDb.gridFs.findOne(MongoDBObject("mapped_id" -> project.id))
                    
29        photo match {
                    
                
DataSets.scala https://github.com/delving/culture-hub.git | Scala | 80 lines
                    
28          case Accepts.Json() =>
                    
29            val sets = DataSet.dao.findAll()
                    
30            val smallSets = sets.map { set =>
                    
41      implicit request =>
                    
42        val maybeDataSet = DataSet.dao.findBySpecAndOrgId(spec, configuration.orgId)
                    
43        if (maybeDataSet.isEmpty) {
                    
69        val formats = maybeFormats.map(_.split(",").toSeq.map(_.trim).filterNot(_.isEmpty)).getOrElse(Seq.empty)
                    
70        val query = MongoDBObject("spec" -> Pattern.compile(q, Pattern.CASE_INSENSITIVE))
                    
71        val sets = DataSet.dao.find(query).filter { set =>
                    
                
DataObjectConverter.scala https://code.google.com/p/sgine/ | Scala | 108 lines
                    
6import annotation.tailrec
                    
7import com.mongodb.casbah.commons.{MongoDBList, MongoDBListBuilder, MongoDBObject}
                    
8import collection.mutable.ListBuffer
                    
16trait DataObjectConverter {
                    
17  def fromDBObject(db: MongoDBObject): AnyRef
                    
18
                    
24
                    
25  def fromDBObject[T](db: MongoDBObject) = {
                    
26    val clazz = Class.forName(db.as[String]("class"))
                    
26    val clazz = Class.forName(db.as[String]("class"))
                    
27    val converter = findConverter(clazz)
                    
28    converter.fromDBObject(db).asInstanceOf[T]
                    
31  def toDBObject(obj: AnyRef) = {
                    
32    val converter = findConverter(obj.getClass)
                    
33    converter.toDBObject(obj)
                    
                
UserRepositoryTests.scala https://github.com/kufi/Filefarmer.git | Scala | 87 lines
                    
2import ch.filefarmer.repositories.UserRepository
                    
3import com.mongodb.casbah.commons.MongoDBObject
                    
4import ch.filefarmer.poso.User
                    
21			
                    
22			val q = MongoDBObject("_id" -> user.id)
                    
23			
                    
23			
                    
24			mongoDB("users").findOne(q) should be('defined)
                    
25		}
                    
                
NameIndexer.scala https://gitlab.com/18runt88/twofishes | Scala | 76 lines
                    
29    val nameSize = NameIndexDAO.collection.count()
                    
30    val nameCursor = NameIndexDAO.find(MongoDBObject())
                    
31      .sort(orderBy = MongoDBObject("name" -> 1)) // sort by nameBytes asc
                    
                
ConversionsSpec.scala https://github.com/etorreborre/casbah.git | Scala | 192 lines
                    
78
                    
79      val jdkEntry = mongo.findOne(MongoDBObject("type" -> "jdk"),
                    
80        MongoDBObject("date" -> 1))
                    
98
                    
99      val jodaEntry = mongo.findOne(MongoDBObject("type" -> "joda"),
                    
100        MongoDBObject("date" -> 1))
                    
126
                    
127      val jdkEntry = mongo.findOne(MongoDBObject("type" -> "jdk"),
                    
128        MongoDBObject("date" -> 1))
                    
146
                    
147      val jdkEntry = mongo.findOne(MongoDBObject("type" -> "jdk"),
                    
148        MongoDBObject("date" -> 1))
                    
160
                    
161      val jodaEntry = mongo.findOne(MongoDBObject("type" -> "jdk"),
                    
162        MongoDBObject("date" -> 1))
                    
                
CasbahExamples.scala https://bitbucket.org/brainoutsource/scala-school-2017-1.git | Scala | 64 lines
                    
29
                    
30  val cursor = collectionClient.find(MongoDBObject("params.x" -> 15))
                    
31
                    
45
                    
46  val writeResult: WriteResult = collectionClient.insert(MongoDBObject("_id" -> "0011", "params" -> MongoDBObject("x" -> 1, "y" -> List(0, 0, 1))))
                    
47  writeResult.getN
                    
50
                    
51  val removedDoc: Option[DBObject] = collectionClient.findAndRemove(MongoDBObject("_id" -> "001"))
                    
52  print(removedDoc)
                    
54
                    
55  val removeResult: WriteResult = collectionClient.remove(MongoDBObject("_id" -> "0011", "params" -> MongoDBObject("x" -> 1, "y" -> List(0, 0, 1))))
                    
56
                    
61
                    
62  val saveResult: WriteResult = collectionClient.save(MongoDBObject("_id" -> "9", "params" -> MongoDBObject("x" -> 1, "y" -> List(0, 0, 1))))
                    
63
                    
                
ShapefileWriter.scala https://gitlab.com/18runt88/twofishes | Scala | 107 lines
                    
75
                    
76    val total = MongoGeocodeDAO.count(MongoDBObject("hasPoly" -> true))
                    
77
                    
78    val records =
                    
79      MongoGeocodeDAO.find(MongoDBObject("hasPoly" -> true))
                    
80
                    
                
Logs.scala https://github.com/delving/culture-hub.git | Scala | 44 lines
                    
18    implicit request =>
                    
19      val cursor: SalatMongoCursor[Log] = Log.dao.find(MongoDBObject("task_id" -> taskId)).limit(500).sort(MongoDBObject("date" -> 1))
                    
20      val (logs, skipped) = if (lastCount != None && lastCount.get > 0) {
                    
38      {
                    
39        val cursor: SalatMongoCursor[Log] = Log.dao.find(MongoDBObject("task_id" -> taskId)).sort(MongoDBObject("date" -> 1))
                    
40        Ok(cursor.map(log => log.date + "\t" + s"[${log.orgId}] " + log.level.name.toUpperCase + "\t" + log.node + "\t" + log.message).mkString("\n"))
                    
                
MongoRepository.scala http://tratata.googlecode.com/svn/trunk/ | Scala | 42 lines
                    
10import com.mongodb.DBObject
                    
11import com.mongodb.casbah.commons.MongoDBObject;
import com.mongodb.casbah.Imports._;

object MongoDataSource {
                    
12	 //val mongodbConfigPrefix = "akka.remote.server.server.client.storage.mongodb"
                    
22	
                    
23	def findOne[T](qr:Query[T]):Option[BasicData]={
                    
24		collection(qr.collectionName).findOne(qr.queryObject).map(create(_,qr.clazz))
                    
25	};
	
                    
26	def find[T](qr:Query[T]):List[BasicData]={
                    
27		collection(qr.collectionName).find(qr.queryObject).map(create(_,qr.clazz)).toList				
                    
                
MongoDataGetter.scala git://github.com/btarbox/Log4ScalaFugue.git | Scala | 44 lines
                    
34    try {
                    
35      for { x <- conn.find().sort(MongoDBObject("timeColumn" -> "1")); thisTime = x.get(timeColumn); if(thisTime != null)} {
                    
36        val line = x.get(timeColumn).toString
                    
                
CoreWrappersSpec.scala git://github.com/ymasory/scala-corpus.git | Scala | 178 lines
                    
132      coll.drop()
                    
133      coll.insert(MongoDBObject("foo" -> "bar"))
                    
134      coll must notBeNull
                    
150
                    
151  "findOne operations" should {
                    
152    shareVariables()
                    
158      coll.insert(MongoDBObject("foo" -> "bar"))
                    
159      val basicFind = coll.find(MongoDBObject("foo" -> "bar")) 
                    
160
                    
163
                    
164      val findOne = coll.findOne()
                    
165
                    
167
                    
168      val findOneMatch = coll.findOne(MongoDBObject("foo" -> "bar")) 
                    
169
                    
                
Mongo.scala https://github.com/mostlygeek/PlayByExample.git | Scala | 50 lines
                    
28  /**
                    
29   * looks for a document within mongo, if it can't find it
                    
30   * it will create it and tell the user to reload the page.
                    
32  def create(id: String) = Action {
                    
33    col.findOneByID(id)  match { 
                    
34      case None => { 
                    
35          // the += operator allows Docs to be added to mongo easily 
                    
36          col += MongoDBObject("_id" -> id, "created" -> true)
                    
37          Ok("created: " + id + ", refresh to load record")
                    
43  def show(id: String) = Action {
                    
44    col.findOneByID(id) match {
                    
45      case None => Ok("Not, Found")
                    
                
GridFS.scala git://github.com/mongodb/casbah.git | Scala | 247 lines
                    
212
                    
213  def findOne[A <% DBObject](query: A): Option[GridFSDBFile] = {
                    
214    filesCollection.findOne(query) match {
                    
223
                    
224  def findOne(id: ObjectId): Option[GridFSDBFile] = findOne(MongoDBObject("_id" -> id))
                    
225
                    
225
                    
226  def findOne(filename: String): Option[GridFSDBFile] = findOne(MongoDBObject("filename" -> filename))
                    
227
                    
                
user.scala git://github.com/whiter4bbit/oauth.git | Scala | 51 lines
                    
22       val user = User(login, password, generateKey, generateKey)
                    
23       if (self.users.find(MongoDBObject("login" -> login)).size == 0) {       
                    
24          self.users.insert(MongoDBObject("login" -> login,
                    
35
                    
36   def find(consumerKey: String): Validation[String, User] = {
                    
37       (for {
                    
37       (for {
                    
38          found <- self.users.findOne(MongoDBObject("consumerKey" -> consumerKey));
                    
39	  login <- found.getAs[String]("login");
                    
                
MediaSpec.scala git://github.com/leodagdag/persistance.git | Scala | 135 lines
                    
46      running(FakeApplication()) {
                    
47        val newPost = Media.findOne(MongoDBObject("title" -> "titre"))
                    
48        newPost mustNotEqual None
                    
53      running(FakeApplication()) {
                    
54        val newPost = Media.findOneByID(savedId)
                    
55        newPost mustNotEqual None
                    
70
                    
71    "find all" in {
                    
72      running(FakeApplication()) {
                    
72      running(FakeApplication()) {
                    
73        val all = Media.find(MongoDBObject()).toList
                    
74        all.size mustEqual 13
                    
83
                    
84    "find by page" in {
                    
85      running(FakeApplication()) {
                    
                
BeerDemo.scala git://github.com/bfritz/mongodb-from-scala.git | Scala | 57 lines
                    
10
                    
11  // we need some beer; let's start with Casbah's MongoDBObject...
                    
12  val guinness: DBObject = MongoDBObject(
                    
18  // ...more beer via Scala 2.8 builder
                    
19  val builder =MongoDBObject.newBuilder
                    
20  builder += "name" -> "Bully Porter"
                    
32  // let's add a beer to pick on...
                    
33  val keystoneLight: DBObject = MongoDBObject(
                    
34    "name" -> "Keystone Light",
                    
44  // now where did I put that beer!?
                    
45  fridge.find().foreach { b =>
                    
46    println("Let's drink a %s!".format(b("name")))
                    
48
                    
49  // let's find a good US beer
                    
50  val query = (
                    
                
S2CoveringAkkaWorkers.scala https://gitlab.com/18runt88/twofishes | Scala | 192 lines
                    
45  def calculateCoverFromMongo(msg: CalculateCoverFromMongo) {
                    
46    val records = PolygonIndexDAO.find(MongoDBObject("_id" -> MongoDBObject("$in" -> msg.polyIds)))
                    
47    records.option = Bytes.QUERYOPTION_NOTIMEOUT
                    
                
CasbahQuerying.scala git://github.com/bwmcadams/mongoScalaWebinar.git | Scala | 54 lines
                    
14
                    
15  // What about querying?  Lets find all the non-US events
                    
16
                    
16
                    
17  for (x <- mongo.find(MongoDBObject("location.country" -> 
                    
18                        MongoDBObject("$ne" -> "USA")))) println(x)
                    
24
                    
25  for (x <- mongo.find(MongoDBObject("location.country" -> MongoDBObject(
                    
26                       "$ne" -> "USA",
                    
36
                    
37  for (x <- mongo.find(q)) println(x)
                    
38
                    
49
                    
50  for (x <- mongo.find(dateQ, MongoDBObject("name" -> true, "date" -> true))) println(x)
                    
51
                    
                
MongoPersister.scala git://github.com/etaoins/choonweb.git | Scala | 109 lines
                    
12  // Create our indexes
                    
13  trackColl.ensureIndex(MongoDBObject("path" -> 1), null, true)
                    
14  trackColl.ensureIndex(MongoDBObject("tag.artist" -> 1))
                    
14  trackColl.ensureIndex(MongoDBObject("tag.artist" -> 1))
                    
15  trackColl.ensureIndex(MongoDBObject("tag.album" -> 1))
                    
16  trackColl.ensureIndex(MongoDBObject("tag.title" -> 1))
                    
16  trackColl.ensureIndex(MongoDBObject("tag.title" -> 1))
                    
17  trackColl.ensureIndex(MongoDBObject("keywords" -> 1))
                    
18  
                    
18  
                    
19  scanColl.ensureIndex(MongoDBObject("finished" -> -1))
                    
20  
                    
27        case AudioFileScanned(relativePath, audioFile) =>
                    
28          def tagInformation(tag : org.jaudiotagger.tag.Tag) : MongoDBObject = {
                    
29            val tagBuilder = MongoDBObject.newBuilder
                    
                
Feed.scala git://github.com/HendraWijaya/syndor.git | Scala | 92 lines
                    
43  def grabForFetching: Option[Feed] = {
                    
44    return collection.findAndModify(
                    
45      query = MongoDBObject("fetchStatus.fetching" -> false),
                    
45      query = MongoDBObject("fetchStatus.fetching" -> false),
                    
46      fields = MongoDBObject(),
                    
47      sort = MongoDBObject(),
                    
81    entries.foreach { entry =>
                    
82      FeedItem.findOne(MongoDBObject("link" -> entry.getLink)) orElse {
                    
83        FeedItem.insert(FeedItem.make(feed, entry))
                    
89    // Resetting fetching status
                    
90    update(MongoDBObject("fetchStatus.fetching" -> true), $set("fetchStatus.fetching" -> false))
                    
91  }
                    
                
SprayMongoAuthenticator.scala https://github.com/ctcarrier/ouchload.git | Scala | 35 lines
                    
7import com.mongodb.casbah.MongoConnection
                    
8import com.mongodb.casbah.commons.MongoDBObject
                    
9import com.mongodb.casbah.commons.Imports._
                    
25        val db = MongoConnection()("mycotrack")("users")
                    
26        val userResult = db.findOne(MongoDBObject("username" -> user) ++ ("password" -> pass))
                    
27        userResult.map(grater[BasicUserContext].asObject(_))
                    
                
DataSetStatistics.scala https://github.com/delving/culture-hub.git | Scala | 113 lines
                    
23  def getStatisticsFile = {
                    
24    hubFileStores.getResource(OrganizationConfigurationHandler.getByOrgId(context.orgId)).findOne(MongoDBObject("orgId" -> context.orgId, "spec" -> context.spec, "uploadDate" -> context.uploadDate))
                    
25  }
                    
27  def getHistogram(path: String)(implicit configuration: OrganizationConfiguration): Option[Histogram] = DataSetStatistics.dao.frequencies.
                    
28    findByParentId(_id, MongoDBObject("context.orgId" -> context.orgId, "context.spec" -> context.spec, "context.uploadDate" -> context.uploadDate, "path" -> path)).toList.headOption.
                    
29    map(_.histogram)
                    
110
                    
111  def getMostRecent(orgId: String, spec: String, schema: String) = find(MongoDBObject("context.orgId" -> orgId, "context.spec" -> spec, "context.schema" -> schema)).$orderby(MongoDBObject("_id" -> -1)).limit(1).toList.headOption
                    
112
                    
                
event.scala git://github.com/whiter4bbit/oauth.git | Scala | 64 lines
                    
17   def add(event: Event, consumerKey: String): Validation[String, Event] = {
                    
18      if (self.events.find(MongoDBObject("name" -> event.name)).size == 0) {
                    
19          self.events.insert(MongoDBObject("name" -> event.name,
                    
32   def mine(consumerKey: String): Validation[String, List[Event]] = {
                    
33      self.events.find(MongoDBObject("consumerKey" -> consumerKey)).map((event) => {
                    
34         for {
                    
56         id <- objectId(eventId);
                    
57	 modified <- self.events.findAndModify(MongoDBObject("_id" -> id), 
                    
58	                                       MongoDBObject("$addToSet" -> MongoDBObject("attendees" -> consumerKey)))
                    
                
SlugIndexer.scala https://gitlab.com/18runt88/twofishes | Scala | 184 lines
                    
64  def findFeature(fid: StoredFeatureId): Option[GeocodeServingFeature] = {
                    
65    val ret = MongoGeocodeDAO.findOne(MongoDBObject("_id" -> fid.longId)).map(_.toGeocodeServingFeature)
                    
66    if (ret.isEmpty) {
                    
66    if (ret.isEmpty) {
                    
67      println("couldn't find %s".format(fid))
                    
68    }
                    
71
                    
72  def findParent(fid: StoredFeatureId): Option[GeocodeFeature] = {
                    
73    parentMap.getOrElseUpdate(fid, findFeature(fid).map(_.feature))
                    
103    })
                    
104  // println("failed to find any slug")
                    
105    return None
                    
114      fid <- StoredFeatureId.fromHumanReadableString(id)
                    
115      servingFeature <- findFeature(fid)
                    
116      if (servingFeature.scoringFeatures.population > 0 ||
                    
                
User.scala git://github.com/leodagdag/persistance.git | Scala | 35 lines
                    
27  def authenticate(username: String, password: String): Option[User] = {
                    
28    this.findOne(MongoDBObject("username" -> username, "password" -> password))
                    
29  }
                    
31  def byUsername(username: String): Option[User] = {
                    
32    this.findOne(MongoDBObject("username" -> username))
                    
33  }
                    
                
Database.scala https://gitlab.com/williamhogman/checklist.git | Scala | 64 lines
                    
19  def deref() = {
                    
20    val findable = implicitly[IdFindable[T]]
                    
21    findable.byId(id)  
                    
27
                    
28  protected def find(query: MongoDBObject): Iterator[MongoDBObject] =
                    
29    mdbcol.find(query) map(wrapDBObj)
                    
30
                    
31  protected def findOne(query: MongoDBObject) : Option[MongoDBObject] =
                    
32    mdbcol.findOne(query) map(wrapDBObj)
                    
36
                    
37  protected def update(query: MongoDBObject, to: MongoDBObject) =
                    
38    mdbcol.update(query, to)
                    
47  def byId[T: IdFindable](id: ObjectId) = {
                    
48    val findable = implicitly[IdFindable[T]]
                    
49    findable.byId(id)
                    
                
MongoDBDatastore.scala https://code.google.com/p/sgine/ | Scala | 86 lines
                    
9import org.sgine.reflect.EnhancedClass
                    
10import com.mongodb.casbah.commons.{MongoDBObjectBuilder, MongoDBObject}
                    
11import com.mongodb.DBObject
                    
26
                    
27  protected def deleteInternal(id: UUID) = collection.findAndRemove(MongoDBObject("_id" -> id)) != None
                    
28
                    
46    }.toMap
                    
47    val builder = MongoDBObject.newBuilder
                    
48    ec.caseValues.foreach(cv => if (cv.name != "id" && defaults(cv.name) != cv[Any](example)) {
                    
52    val query = toDotNotation("", wrapDBObj(builder.result()))
                    
53    collection.find(query).map(entry => {
                    
54      DataObjectConverter.fromDBValue(entry)
                    
66
                    
67  private def toDotNotation(pre: String, values: MongoDBObject, builder: MongoDBObjectBuilder = MongoDBObject.newBuilder): DBObject = {
                    
68    if (values.isEmpty) {
                    
                
PollResponse.scala https://bitbucket.org/wbillingsley/ibmongo-2012-old-version-duct-tape-not-maintained.git | Scala | 77 lines
                    
58
                    
59  def findVote(pollRef: Ref[Poll], readerRef: Ref[Reader], sessionOpt: Option[String]) = {
                    
60    readerRef.fetch match {
                    
61      case RefItself(r) => {
                    
62        val ccOpt = sdao.findOne(MongoDBObject("poll" -> pollRef.getId, "reader" -> r.id))
                    
63        ccOpt
                    
65      case _ => {
                    
66        val ccOpt = sdao.findOne(MongoDBObject("poll" -> pollRef.getId, "session" -> sessionOpt))
                    
67        ccOpt
                    
72  def getPollResponses(pollRef:Ref[Poll]) = {
                    
73    val res = sdao.find(MongoDBObject("poll" -> pollRef.getId))
                    
74    res.toSeq
                    
                
UserDAO.scala https://github.com/michel-kraemer/spamihilator-setup-wizard.git | Scala | 70 lines
                    
42    * @return the database object */
                    
43  private implicit def userToDBObject(user: User): DBObject = MongoDBObject(
                    
44    "userName" -> user.userName,
                    
50  
                    
51  override def find(): Iterable[User] = coll map toUser
                    
52  
                    
52  
                    
53  /** Finds a user with the given name
                    
54    * @param userName the user's name
                    
57  def find(userName: String): Option[User] =
                    
58    coll.findOne(MongoDBObject("userName" -> userName)) map toUser
                    
59  
                    
67  def update(user: User) {
                    
68    coll.update(MongoDBObject("_id" -> user.id), user)
                    
69  }
                    
                
PolygonIndexer.scala https://gitlab.com/18runt88/twofishes | Scala | 59 lines
                    
23    val polygonSize = PolygonIndexDAO.collection.count()
                    
24    val usedPolygonSize = MongoGeocodeDAO.count(MongoDBObject("hasPoly" -> true))
                    
25
                    
26    val hasPolyCursor =
                    
27      MongoGeocodeDAO.find(MongoDBObject("hasPoly" -> true))
                    
28        .sort(orderBy = MongoDBObject("_id" -> 1)) // sort by _id asc
                    
41      toFindPolys: Map[Long, ObjectId] = group.filter(f => f.hasPoly).map(r => (r._id, r.polyId)).toMap
                    
42      polyMap: Map[ObjectId, PolygonIndex] = PolygonIndexDAO.find(MongoDBObject("_id" -> MongoDBObject("$in" -> toFindPolys.values.toList)))
                    
43        .toList
                    
                
User.scala https://gitlab.com/Memoria/Memoria | Scala | 66 lines
                    
16
                    
17  def findAll () : mutable.Set[UserModel] = {
                    
18    val result : mutable.Set[UserModel] = mutable.Set[UserModel]()
                    
18    val result : mutable.Set[UserModel] = mutable.Set[UserModel]()
                    
19    val users = User.coll.find()
                    
20    for(user <- users) {
                    
32
                    
33  def findUser (login : String, password : String) : Option[UserModel] = {
                    
34    var result : Option[UserModel] = None
                    
34    var result : Option[UserModel] = None
                    
35    val q = MongoDBObject("login" -> login, "password" -> password )
                    
36    val cursor = User.coll.findOne(q)
                    
51    val coll = User.db("users")
                    
52    val builder = MongoDBObject.newBuilder
                    
53    builder += "login" -> userModel.login
                    
                
JodaGridFS.scala git://github.com/mongodb/casbah.git | Scala | 253 lines
                    
218
                    
219  def findOne[A <% DBObject](query: A): Option[JodaGridFSDBFile] = {
                    
220    filesCollection.findOne(query) match {
                    
229
                    
230  def findOne(id: ObjectId): Option[JodaGridFSDBFile] = findOne(MongoDBObject("_id" -> id))
                    
231
                    
231
                    
232  def findOne(filename: String): Option[JodaGridFSDBFile] = findOne(MongoDBObject("filename" -> filename))
                    
233
                    
                
mongo.scala git://github.com/timperrett/helix.git | Scala | 145 lines
                    
17    def listProjectsAlphabetically(limit: Int, offset: Int): List[Project] = 
                    
18      ProjectDAO.find(MongoDBObject("setupComplete" -> true))
                    
19        .limit(limit)
                    
24    def listFiveNewestProjects: List[Project] = 
                    
25      ProjectDAO.find(MongoDBObject("setupComplete" -> true)
                    
26        ).limit(5).sort(orderBy = MongoDBObject("_id" -> -1)).toList
                    
28    def listFiveMostActiveProjects: List[Project] = 
                    
29      ProjectDAO.find(MongoDBObject("setupComplete" -> true)
                    
30        ).limit(5).sort(orderBy = MongoDBObject("activityScore" -> -1)).toList
                    
32    /** global lists **/
                    
33    def listScalaVersions = ScalaVersionDAO.find(MongoDBObject()
                    
34      ).sort(orderBy = MongoDBObject(
                    
75    def findContributorByLogin(login: String): Option[Contributor] = 
                    
76      ContributorDAO.findOne(MongoDBObject("login" -> login))
                    
77    
                    
                
MongoDAO.scala https://bitbucket.org/marcromera/dsbw-1213t.git | Scala | 61 lines
                    
8import com.novus.salat.Context
                    
9import com.mongodb.casbah.commons.MongoDBObject
                    
10import dsbw.mongo.SalatContext.ctx
                    
31
                    
32  def findOne[T<: AnyRef](query:Map[String,T]): Option[ObjectType] = salatDao.findOne(query)
                    
33
                    
33
                    
34  def findOneByID(id:ObjectId): Option[ObjectType] = salatDao.findOneByID(id)
                    
35
                    
35
                    
36  def findByIds(ids:Set[ObjectId]) =  salatDao.find("_id" $in ids).toSet
                    
37
                    
37
                    
38  def findAll = salatDao.find((MongoDBObject.empty))
                    
39
                    
                
EntityMentionAlignmentService.scala https://github.com/riedelcastro/cmon-noun.git | Scala | 102 lines
                    
4import org.riedelcastro.cmonnoun.clusterhub.EntityService.ByIds
                    
5import com.mongodb.casbah.commons.MongoDBObject
                    
6import com.mongodb.casbah.Imports._
                    
22  def entityIdsFor(mentionId: Any): TraversableOnce[Any] = {
                    
23    for (dbo <- coll.find(MongoDBObject("mention" -> mentionId))) yield {
                    
24      dbo.as[String]("entity")
                    
28  def entities(): TraversableOnce[Any] = {
                    
29    for (dbo <- coll.find()) yield {
                    
30      dbo.as[String]("entity")
                    
35  def mentionIdsFor(entityId: Any): TraversableOnce[Any] = {
                    
36    for (dbo <- coll.find(MongoDBObject("entity" -> entityId))) yield {
                    
37      dbo.as[Any]("mention")
                    
41  def mentionsIdsFor(entityIds: Stream[Any]): TraversableOnce[Alignment] = {
                    
42    for (dbo <- coll.find(MongoDBObject("entity" -> MongoDBObject("$in" -> entityIds)))) yield {
                    
43      val m = dbo.as[Any]("mention")
                    
                
DeviceController.scala git://github.com/joakim666/simple-scheduler.git | Scala | 34 lines
                    
4import org.fusesource.scalate.TemplateEngine
                    
5import com.mongodb.casbah.commons.MongoDBObject
                    
6import org.slf4j.LoggerFactory
                    
21        devices.foreach(d => {
                    
22          val events = EventDao.find(ref = MongoDBObject("deviceId" -> d.id)).toList
                    
23          deviceEvents += d -> events
                    
                
Post.scala git://github.com/leodagdag/persistance.git | Scala | 76 lines
                    
42  def addComment(id: ObjectId, comment: Comment) {
                    
43    val post = this.findOneByID(id)
                    
44    post match {
                    
55
                    
56  def featured: Option[Post] = Post.findOne(MongoDBObject("featured" -> true))
                    
57
                    
73  def updateFeatured() {
                    
74    collection.updateMulti(MongoDBObject("featured" -> true), $set("featured" -> false))
                    
75  }
                    
                
ProcessJobPosting.scala https://gitlab.com/thugside/sync | Scala | 176 lines
                    
8import com.mongodb.casbah.MongoCollection
                    
9import com.mongodb.casbah.commons.MongoDBObject
                    
10import com.mongodb.casbah.Imports._
                    
44  def toWords(lines: List[String]) = lines flatMap { line =>
                    
45    "[a-zA-Z]+".r findAllIn line map (_.toLowerCase)
                    
46  }
                    
76  def getSkills(content: String): List[String] = {
                    
77    skillsPattern.findFirstMatchIn(content).map(_ group 1) match {
                    
78      case Some(skills) => (skills replaceAll("&nbsp;", "")).split(",").toList
                    
84    emailPattern
                    
85      .findAllMatchIn(content)
                    
86      .map(s => s.toString())
                    
93    phonePattern
                    
94      .findAllMatchIn(content)
                    
95      .map(s => s.toString())
                    
                
Registration.scala https://bitbucket.org/wbillingsley/ibmongo-2012-old-version-duct-tape-not-maintained.git | Scala | 66 lines
                    
55  def findByReader(rid:ObjectId) = {
                    
56    val cursor = sdao.find(MongoDBObject("reader" -> rid))
                    
57    cursor.toSeq
                    
59
                    
60  def findByReaderAndBook(r:Ref[Reader], b:Ref[Book]):TraversableOnce[Registration] = {
                    
61    (for (rid <- r.getId; bid <- b.getId) yield {
                    
61    (for (rid <- r.getId; bid <- b.getId) yield {
                    
62      sdao.find(MongoDBObject("reader" -> rid, "book" -> bid))
                    
63    }) getOrElse Seq.empty[Registration]
                    
                
Presentation.scala https://bitbucket.org/wbillingsley/ibmongo-2012-old-version-duct-tape-not-maintained.git | Scala | 71 lines
                    
53    val result = idOpt map { oid =>
                    
54      val ccSeq = sdao.find(MongoDBObject("entries" -> oid))
                    
55      ccSeq.toSeq
                    
                
ServiceRegister.scala https://gitlab.com/SharkyLV/Mirio.git | Scala | 40 lines
                    
23    case RegisterServiceEvent(service, id) =>
                    
24      serviceCol.insert(MongoDBObject("service"->id,"path"->service.path.toString))
                    
25      println("Registered "+service.toString())
                    
27    case ListServicesEvent() =>
                    
28      val toList = serviceCol.find("path" $exists true)
                    
29      val strings: Iterator[String] = for (x <- toList) yield x.getAsOrElse[String]("path", "").toString
                    
                
TemplatedDao.scala https://github.com/nexus49/invsys.git | Scala | 99 lines
                    
14
                    
15  def findAll(): List[Templated] = {
                    
16    val templates = Template.findAll
                    
22
                    
23      for (result <- collection.find) {
                    
24        val item = fac(result, t)
                    
31
                    
32  def findAll(template: Template): List[Templated] = {
                    
33    val collection = CollectionFactory.getCollection(template.collectionName)
                    
34    val values = new mutable.ListBuffer[Templated]
                    
35    val query = MongoDBObject.apply(CollectionFactory.templateIdColumn -> template.id)
                    
36    val rslt = collection.find(query)
                    
44
                    
45  def findFirstById[T](id: ObjectId, template: Template): Templated = {
                    
46    val collection = CollectionFactory.getCollection(template.collectionName)
                    
                
 

Source

Language