100+ results results for 'MongoDBObject find lang:Scala' (791 ms)
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 DateTypeMr00.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) 99User.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 }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) 162MaxTimeSpec.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]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) 160Libraries.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 }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)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")))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 =>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) 82DAOTest.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) 156Par00.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) 159SlugMapping.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).orNullMongoCollection.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)) 253QueryIntegrationSpec.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))Mr05.scala http://scaly.googlecode.com/svn/trunk/ | Scala | 212 lines
33import com.mongodb.casbah.MongoConnection 34import com.mongodb.casbah.commons.MongoDBObject 35import com.mongodb.casbah.MongoCursor 118 119 val portfsQuery = MongoDBObject("id" -> portfId) 120 120 121 val portfsCursor: MongoCursor = portfsCollecton.find(portfsQuery) 122 131 // Get the bond from the bond collection 132 val bondQuery = MongoDBObject("id" -> id) 133 133 134 val bondCursor: MongoCursor = bondsCollection.find(bondQuery) 135test.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) 177ConversionsSpec.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"),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_NOTIMEOUTOpLog.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 = UpdateOpDefRepo.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" -> decLazyDecodingSpec.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 }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)storage.scala git://github.com/whiter4bbit/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").toStringDataSetEventLog.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) 72ArchiveRepository.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) 52SalatExamples.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) 38Article.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 }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_idFileStorage.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",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.nextMongoStorageBackend.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, // queryPlainCasbah.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 ascConversionsSpec.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)))) 63ShapefileWriter.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)) 80Logs.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)).toListMongoDataGetter.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).toStringCoreWrappersSpec.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")) 169Mongo.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)) 227user.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_NOTIMEOUTCasbahQuerying.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) 51MongoPersister.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.newBuilderFeed.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 112event.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.toSeqUserDAO.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 .toListUser.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.loginJodaGridFS.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)) 233mongo.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)) 77MongoDAO.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)) 39EntityMentionAlignmentService.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 -> eventsPost.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(" ", "")).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.toSeqServiceRegister.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", "").toStringTemplatedDao.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)Blog.scala git://github.com/leodagdag/persistance.git | Scala | 169 lines
10import org.bson.types.ObjectId 11import com.mongodb.casbah.commons.MongoDBObject 12 84 implicit request => 85 val post = Post.findOneByID(ObjectId.massageToObjectId(id)) 86 post match { 95 implicit request => 96 val post = Post.findOneByID(ObjectId.massageToObjectId(id)) 97 post match { 136 implicit request => 137 val post = Post.findOneByID(ObjectId.massageToObjectId(id)) 138 post match { 154 updPost => { 155 val post = Post.findOneByID(ObjectId.massageToObjectId(id)) 156 post match {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 + ".*").rDocumentDAO.scala https://github.com/michel-kraemer/spamihilator-setup-wizard.git | Scala | 83 lines
48 * @return the database object */ 49 private implicit def documentToDBObject(doc: Document): DBObject = MongoDBObject( 50 "text" -> doc.text, 55 56 override def find(): Iterable[Document] = coll map { o => 57 val client = (for (id <- o.getAs[ObjectId]("client"); 57 val client = (for (id <- o.getAs[ObjectId]("client"); 58 c <- Database.clientDao.find(id)) yield c) getOrElse { 59 throw new IllegalStateException("Document has an unknown client") 67 def find(client: Client): Iterable[Document] = 68 (coll.find(MongoDBObject("client" -> client.id)) map { o => 69 toDocument(client, o) }).toList 74 def findLatest(client: Client): Option[Document] = { 75 val f = coll.find(MongoDBObject("client" -> client.id)).sort( 76 MongoDBObject("date" -> -1))Models.scala https://github.com/delving/culture-hub.git | Scala | 158 lines
64 65 def valueOf(what: String) = values find { _.name == what } 66 } 85 86 def isCancelled = Task.dao(orgId).findOne(MongoDBObject("_id" -> _id, "state.name" -> TaskState.CANCELLED.name)).isDefined 87 102 103 def list(taskType: TaskType) = find(MongoDBObject("taskType.name" -> taskType.name)).toList 104 104 105 def list(state: TaskState) = find(MongoDBObject("state.name" -> state.name, "node" -> getNode)).sort(MongoDBObject("queuedAt" -> 1)).toList 106 106 107 def listAll() = find(MongoDBObject()).sort(MongoDBObject("queuedAt" -> 1)).toList 108DataSetImport.scala https://github.com/delving/culture-hub.git | Scala | 156 lines
13import models.Details 14import com.mongodb.casbah.commons.MongoDBObject 15import play.api.libs.ws.WS 53 val entries = allEntries.groupBy { e => 54 if (FileName.findAllMatchIn(e._1).isEmpty) { 55 e._1 66 67 entries.find(e => e._1.contains("dataset_facts.txt")).map { facts => 68 76 val spec = factsMap("spec") 77 val set = DataSet.dao.findOne(MongoDBObject("spec" -> spec)) getOrElse { 78 109 val commands: Map[String, Future[String]] = entries 110 .filterNot(f => FileName.findAllMatchIn(f._1).isEmpty) 111 .filterNot(_._1.contains("_imported"))PrototypeController.scala https://gitlab.com/williamhogman/checklist.git | Scala | 82 lines
13import com.mongodb.casbah.Imports.{DBObject, DBList} 14import com.mongodb.casbah.commons.{MongoDBObject, MongoDBList} 15 31 32 var user = db("users").findOne(DBObject("name" -> username)).get 33 db("users").update(LibraryDAO.scala https://github.com/scala-phase/scala-orms.git | Scala | 73 lines
19 // author collection has a unique index on firstName, lastName 20 ids(MongoDBObject("firstName" -> firstName, "lastName" -> lastName)).firstOption 21 } 29 val bookIds = bookAuthor.primitiveProjectionsByParentId[ObjectId](parentId = author.id, field = "bookId") 30 BookDAO.find(ref = MongoDBObject("_id" -> MongoDBObject("$in" -> MongoDBList(bookIds: _*)))) 31 .sort(MongoDBObject("title" -> 1)) 48 def idByTitle(title: String): Option[ObjectId] = { 49 ids(MongoDBObject("title" -> title)).firstOption 50 } 53 val bookIds = bookAuthor.primitiveProjectionsByParentId[ObjectId](parentId = book.id, field = "authorId") 54 AuthorDAO.find(ref = MongoDBObject("_id" -> MongoDBObject("$in" -> MongoDBList(bookIds: _*)))) 55 .sort(MongoDBObject("lastName" -> 1)) 59 def borrowalHistoryForBook(book: Book): List[Borrowal] = { 60 borrowal.findByParentId(book.id). 61 sort(MongoDBObject("scheduledToReturnOn" -> -1)).Model.scala git://github.com/leodagdag/persistance.git | Scala | 28 lines
16 } 17 dao.find(MongoDBObject()).skip(skip).limit(PAGE_SIZE).toList 18 } 20 def all(implicit dao: SalatDAO[ObjectType, ObjectId]): List[ObjectType] = { 21 dao.find(MongoDBObject.empty).toList 22 }MongoGeocodeStorageService.scala https://gitlab.com/18runt88/twofishes | Scala | 84 lines
21 def getNameIndexByIdLangAndName(id: StoredFeatureId, lang: String, name: String): Iterator[NameIndex] = { 22 val nameCursor = NameIndexDAO.find(MongoDBObject("fid" -> id.longId, "lang" -> lang, "name" -> name)) 23 nameCursor.option = Bytes.QUERYOPTION_NOTIMEOUT 36 MongoGeocodeDAO.update(MongoDBObject("_id" -> id.longId), 37 MongoDBObject("$set" -> MongoDBObject("boundingbox" -> grater[BoundingBox].asDBObject(bbox))), 38 false, false) 56 NameIndexDAO.update(MongoDBObject("fid" -> id.longId, "lang" -> lang, "name" -> name), 57 MongoDBObject("$set" -> MongoDBObject("flags" -> flags)), 58 upsert = false, multi = true) 73 MongoGeocodeDAO.update(MongoDBObject("_id" -> id.longId), 74 MongoDBObject("$set" -> MongoDBObject("slug" -> slug)), 75 false, false) 79 MongoGeocodeDAO.update(MongoDBObject("_id" -> id.longId), 80 MongoDBObject("$set" -> MongoDBObject( 81 "displayNames" -> names.map(n => grater[DisplayName].asDBObject(n)))),RevGeoIndexer.scala https://gitlab.com/18runt88/twofishes | Scala | 83 lines
35 def writeRevGeoIndex( 36 restrict: MongoDBObject 37 ) = { 39 40 val revGeoCursor = RevGeoIndexDAO.find(restrict) 41 .sort(orderBy = MongoDBObject("cellid" -> 1)) 76 // in byte order, positives come before negative 77 writeRevGeoIndex(MongoDBObject("cellid" -> MongoDBObject("$gte" -> 0))) 78 writeRevGeoIndex(MongoDBObject("cellid" -> MongoDBObject("$lt" -> 0)))MycoMongoDb.scala git://github.com/JanxSpirit/mycotrack_mongo.git | Scala | 54 lines
43 44 val seq = seqColl.findAndModify(MongoDBObject("_id" -> "projects"), MongoDBObject("seq" -> 1), MongoDBObject("_id" -> 1), false, com.mongodb.casbah.Imports.$inc ("seq" -> 1), true, true).get 45 seq.getAs[Int]("seq").get 46 47 //val counter = counterColl.findOne.get 48MongoDAO.scala https://bitbucket.org/fludwig/dsbw.git | Scala | 79 lines
34 /** Find all documents that match a specific query*/ 35 def findByQuery[T<: AnyRef](query: Map[String, T]) = salatDao.find(query) 36 37 /** Find a document using a query and return it or None if it wasn't found */ 38 def findOne[T<: AnyRef](query:Map[String,T]): Option[ObjectType] = salatDao.findOne(query) 39 40 /** Find a document by id and return it or None if it wasn't found */ 41 def findOneByID(id:ObjectId): Option[ObjectType] = salatDao.findOneById(id) 42 43 /** Find a collection of documents given their ids */ 44 def findByIds(ids:Set[ObjectId]) = salatDao.find("_id" $in ids).toSet 45 46 /** Find all the documents in a collection */ 47 def findAll = salatDao.find((MongoDBObject.empty)) 48ProductRepository.scala git://github.com/olim7t/mongo-scala.git | Scala | 51 lines
25 26 def all: Seq[Product] = products.find().map(fromDb).toSeq 27 27 28 def byId(id: ObjectId): Option[Product] = products.findOneByID(id).map(fromDb) 29 40 41 def removeById(id: ObjectId) = products.remove(MongoDBObject("_id" -> id)) 42ScreenshotDAO.scala https://github.com/michel-kraemer/spamihilator-setup-wizard.git | Scala | 113 lines
43 val gridfs = GridFS(db) 44 gridfs.find(o.getAs[ObjectId]("dataid").get).underlying.getInputStream() 45 } 52 val client = (for (id <- o.getAs[ObjectId]("client"); 53 c <- Database.clientDao.find(id)) yield c) getOrElse { 54 throw new IllegalStateException("Screenshot has an unknown client") 76 def find(client: Client): Iterable[Screenshot] = 77 (coll.find(MongoDBObject("client" -> client.id)) map { 78 s => toScreenshot(client, s) }).toList 84 def find(title: String): Option[Screenshot] = 85 coll.findOne(MongoDBObject("title" -> title)) map toScreenshot 86 101 def delete(screenshot: Screenshot) { 102 coll.findOne(MongoDBObject("_id" -> screenshot.id)) map { obj => 103 coll.remove(obj)FeedUpdaterSpec.scala git://github.com/HendraWijaya/syndor.git | Scala | 139 lines
57 58 verifyFeedItems(FeedItem.find(MongoDBObject()).sort(orderBy = MongoDBObject("publishedDate" -> -1))) 59 59 60 Feed.findOneByID(feed.id) map { updatedFeed => 61 updatedFeed.fetchStatus.fetching should be(false) 68 } orElse { 69 fail("Unable to find updated feed with id %s".format(feed.id)) 70 } 112 113 Feed.findOneByID(feed.id) map { updatedFeed => 114 updatedFeed.fetchStatus.fetching should be(false) 121 } orElse { 122 fail("Unable to find updated feed with id %s".format(feed.id)) 123 }Identification.scala https://bitbucket.org/wbillingsley/ibmongo-2012-old-version-duct-tape-not-maintained.git | Scala | 75 lines
52 /** 53 * Finds an @link{Identification} based on the provider and the provider's id. 54 */ 55 def find(kind: String, provider:String, value:String):ResolvedRef[Identification] = { 56 val ccOpt = sdao.findOne(MongoDBObject("kind" -> kind, "provider" -> provider, "value" -> Some(value))) 57 Ref.fromOptionItem(ccOpt)MongoUnchangedFilter.scala git://github.com/etaoins/choonweb.git | Scala | 36 lines
12 // Is there a file with the same path, size and last modified? 13 val queryBulder = MongoDBObject.newBuilder 14 queryBulder += "path" -> relativePath 18 // We don't actually want any fields but we get _id anyway 19 val existingTrack = trackColl.findOne(queryBulder.result, MongoDBObject("_id" -> 1)) 20Category.scala https://github.com/ngocdaothanh/tivua.git | Scala | 57 lines
7import com.mongodb.casbah.Imports._ 8import com.mongodb.casbah.commons.MongoDBObject 9import org.bson.types.ObjectId 34 def all: Iterable[Category] = { 35 val cur = coll.find().sort(MongoDBObject("position" -> 1)) 36 val buffer = ArrayBuffer[Category]() 43 44 def first(id: String): Option[Category] = coll.findOneByID(new ObjectId(id)).map(mongoToScala) 45ProjectRepositorySpecs.scala https://github.com/sandarenu/task_tracker.git | Scala | 67 lines
19 "check availablity of project id when project id created" in { 20 val project = MongoDBObject(idK -> "1", 21 projectCodeK -> "PRJ-1", 28 "save project" in { 29 val project = MongoDBObject(idK -> "1", 30 projectCodeK -> "PRJ-2", 35 "not save project when project-id already taken" in { 36 val project = MongoDBObject(idK -> "1", 37 projectCodeK -> "PRJ-2", 40 41 val project1 = MongoDBObject(idK -> "2", 42 projectCodeK -> "PRJ-2", 48 49 projectRepo.createNewProject(MongoDBObject(idK -> "1", 50 projectCodeK -> "PRJ-1",Fetcher.scala https://github.com/mikedorseyjr/redpanda.git | Scala | 122 lines
64 // Fetch all of the collection sites for our fetch group. 65 val f_object = MongoDBObject("fetch_group" -> f_group) 66 // Iterate through all of the sites 66 // Iterate through all of the sites 67 for ( l <- j_sites.find(f_object)){ 68 //if ( l("fetch_type").toString == "rss"){ 76 // Empty implementation. Every subclass will implement their own. 77 def job_process( entry: MongoDBObject ) 78 { 88 89 override def job_process( entry: MongoDBObject ) 90 { 102 // Check to make sure we don't have any job entries with this link already. 103 val find_entry = MongoDBObject("title" -> title, 104 "link" -> link,DocumentSpec.scala https://github.com/josa/mongodb-scala-helper.git | Scala | 106 lines
7import com.mongodb.DBObject 8import com.mongodb.casbah.commons.MongoDBObject 9import org.bson.types.ObjectId 26 document.valueTransient = "not included" 27 dbObject = MongoDBObject("valueOne" -> "value one") 28 } 51 52 it("should generate mongodbObject") { 53 DocumentTools.toDBObject(document).get("valueOne") should equal("value one") 55 56 it("should generate a mongodbObject with only two element") { 57 DocumentTools.toDBObject(document).keySet.size should equal(2) 82 def findInMongo(id: ObjectId): DBObject = { 83 MongoProvider.getCollection(document.getClass).findOne(MongoDBObject("_id" -> id)) 84 }RouteAccess.scala https://github.com/delving/culture-hub.git | Scala | 33 lines
30 31 def findAfterForPath(date: Date, pathPattern: Regex) = find(("date" $gt date) ++ MongoDBObject("uri" -> pathPattern.pattern)) 32CasbahRepository.scala https://github.com/desmax74/codemotion-2010.git | Scala | 47 lines
3import scala.collection.mutable.ListBuffer 4import com.mongodb.casbah.commons.{MongoDBObject} 5import org.desmax.repository.BlogRepository 28 // change only the content 29 val query = MongoDBObject(BlogField.title -> post.title, BlogField.date -> post.date) 30 val obj = grater[BlogPost].asDBObject(post) 35 def readByDate(date: Date): List[BlogPost] = { 36 val query = MongoDBObject(BlogField.date -> date) 37 val list = new ListBuffer[BlogPost] 37 val list = new ListBuffer[BlogPost] 38 mongoColl.find(query).foreach(o => list += grater[BlogPost].asObject(o)) 39 list.toList 42 def readByTitle(title: String):BlogPost = { 43 val query = MongoDBObject(BlogField.title -> title) 44 val obj = mongoColl.findOne(query).getFeatureIndexer.scala https://gitlab.com/18runt88/twofishes | Scala | 111 lines
64 // now for each cell, find the matches in our index 65 val candidates = RevGeoIndexDAO.find(MongoDBObject("cellid" -> MongoDBObject("$in" -> cells))) 66 86 val fidSize = MongoGeocodeDAO.collection.count() 87 val fidCursor = MongoGeocodeDAO.find(MongoDBObject()) 88 .sort(orderBy = MongoDBObject("_id" -> 1)) // sort by _id asc 93 group = gCursor.toList 94 toFindPolys: Map[Long, ObjectId] = group.filter(f => f.hasPoly).map(r => (r._id, r.polyId)).toMap 95 polyMap: Map[ObjectId, PolygonIndex] = 95 polyMap: Map[ObjectId, PolygonIndex] = 96 PolygonIndexDAO.find(MongoDBObject("_id" -> MongoDBObject("$in" -> toFindPolys.values.toList))) 97 .toListChatComment.scala https://bitbucket.org/wbillingsley/ibmongo-2012-old-version-duct-tape-not-maintained.git | Scala | 218 lines
49 */ 50 def findByBook(book:Ref[Book], after:Ref[ChatComment], before:Ref[ChatComment], maxElements:Option[Int]):Seq[ChatComment] = { 51 book.getId match { 52 case Some(bid) => { 53 var map = MongoDBObject("book" -> bid) 54 after.getId.foreach{afterId => 59 } 60 val cursor = sdao.find(map).sort(MongoDBObject("_id" -> -1)) 61 maxElements.foreach {max => cursor.limit(max)} 208 def aggEventsCC(b:Ref[Book]) = { 209 sdao.find(Map("_id.book" -> b.getId.getOrElse(new ObjectId()))) 210 } 212 def aggEventsJson(b:Ref[Book]):Seq[String] = { 213 val c = DAO.getCollection("aggChats").find(Map("_id.book" -> b.getId.getOrElse(new ObjectId()))) 214 c.toSeq.map(o => JSON.serialize(o.get("value")))FidMap.scala https://gitlab.com/18runt88/twofishes | Scala | 53 lines
22 val total = MongoGeocodeDAO.collection.count() 23 val geocodeCursor = MongoGeocodeDAO.find(MongoDBObject()) 24 geocodeCursor.option = Bytes.QUERYOPTION_NOTIMEOUT 42 val longidOpt = MongoGeocodeDAO.primitiveProjection[Long]( 43 MongoDBObject("_id" -> fid.longId), "_id") 44 fidMap(fid) = longidOpt.flatMap(StoredFeatureId.fromLong _)controllers.scala https://bitbucket.org/softwarerero/ruc | Scala | 119 lines
51 } 52 val newObj = MongoDBObject("ruc" -> strArr(0), 53 "name" -> strArr(1), 65 66 def find4Ruc = { 67 val ruc = params.get("ruc") 67 val ruc = params.get("ruc") 68 val q = MongoDBObject("ruc" -> ruc) 69 var rucObj: MongoDBObject = null 69 var rucObj: MongoDBObject = null 70 rucs.findOne(q).foreach { x => rucObj = x } 71 if(rucObj == null) flash += ("error" -> "Nada encontrado!") 79 val ruc = params.get("ruc") 80 var rucObj: MongoDBObject = null 81 flash.clear()Post.scala https://bitbucket.org/edofic/poster.git | Scala | 30 lines
24 def all = 25 dao.find(MongoDBObject()).sort(MongoDBObject("_id" -> -1)) 26 26 27 def tagged(tag: String) = dao.find(MongoDBObject("tags" -> tag)).sort(MongoDBObject("_id" -> -1)) 28 28 29 def fromUser(user: String) = dao.find(MongoDBObject("user" -> user)).sort(MongoDBObject("_id" -> -1)) 30}DocumentTools.scala https://github.com/josa/mongodb-scala-helper.git | Scala | 104 lines
8import org.slf4j.LoggerFactory 9import com.mongodb.casbah.commons.MongoDBObject 10 23 24 val builder = MongoDBObject.newBuilder 25 71 def toOBObject(objectId: org.bson.types.ObjectId): DBObject = { 72 MongoDBObject("_id" -> objectId) 73 } 80 if (refAnnotation.association.equals(AssociationType.ONE_TO_ONE)) { 81 val reference = new DocumentManager(field.getType.asInstanceOf[Class[Document]]).findById(dbObject.get(field.getName).asInstanceOf[ObjectId]) 82 referencePostSpec.scala git://github.com/leodagdag/persistance.git | Scala | 132 lines
42 running(FakeApplication()) { 43 val newPost = Post.findOne(MongoDBObject("title" -> "titre")) 44 newPost mustNotEqual None 71 running(FakeApplication()) { 72 val all = Post.find(MongoDBObject()).toList 73 all.size mustEqual 13 82 83 "find by page" in { 84 running(FakeApplication()) { 104 running(FakeApplication()) { 105 val user = User.findOne(MongoDBObject("username" -> "test")).get 106 println("add a comment - user._id=[%s]".format(user._id)) 123 running(FakeApplication()) { 124 val user = User.findOne(MongoDBObject("username" -> "test")).get 125 println("add a comment generate EntityNotFoundException - user._id=[%s]".format(user._id))Global.scala git://github.com/leodagdag/persistance.git | Scala | 54 lines
2import models._ 3import com.mongodb.casbah.commons.MongoDBObject 4 17 i => 18 comments = comments :+ Comment(content = "Comment's content " + i, user = User.findOne(MongoDBObject("username" -> "user")).get) 19 } 21 22 val id = User.findOne(MongoDBObject("username" -> "admin")).get._id 23 (1 to 5).foreach { 40 case Mode.Prod => { 41 val admin = User.findOne(MongoDBObject("admin" -> true)) 42 admin match {IdIndexer.scala https://gitlab.com/18runt88/twofishes | Scala | 51 lines
33 34 val featureCursor = MongoGeocodeDAO.find(MongoDBObject()) 35 featureCursor.option = Bytes.QUERYOPTION_NOTIMEOUTApp.scala https://github.com/tc/casbah-salat-maven-example.git | Scala | 28 lines
20 21 val found = EmployeeDAO.findOne(MongoDBObject("name" -> "Foo")) 22 println("Found record for name ->Foo:" + found)BandSlurper.scala https://github.com/robb1e/Gig-Recommender.git | Scala | 85 lines
26 27 def init = configCollection.findOne(MongoDBObject("reload" -> true)).map(res => load) 28 41 bandsCase.foreach(b => { 42 bandsCollection.findOne(MongoDBObject("mbid" -> b.mbid.trim)) match { 43 case Some(i) => println("ignoring " + b.name) 61 val similarBands = (someXml \ "similarartists" \ "artist").map(s => Band((s \ "name").text.trim, (s \ "mbid").text.trim)) 62 similarBands.foreach(s => similarCollection.findOne(MongoDBObject("mbid" -> s.mbid)) match { 63 case Some(result) => { 63 case Some(result) => { 64 similarCollection.update(MongoDBObject("mbid" -> s.mbid), MongoDBObject("$addToSet" -> MongoDBObject("like" -> MongoDBObject("name" -> name, "mbid" -> mbid)))) 65 } 67 similarCollection += MongoDBObject("name" -> s.name, "mbid" -> s.mbid) 68 similarCollection.update(MongoDBObject("mbid" -> s.mbid), MongoDBObject("$addToSet" -> MongoDBObject("like" -> MongoDBObject("name" -> name, "mbid" -> mbid)))) 69 }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.getIdStringUser.scala https://bitbucket.org/edofic/poster.git | Scala | 29 lines
25 def find(username: String): Option[User] = 26 dao findOne MongoDBObject("username" -> username) 27S2CoveringIndexer.scala https://gitlab.com/18runt88/twofishes | Scala | 49 lines
15 val polygonSize = S2CoveringIndexDAO.collection.count() 16 val usedPolygonSize = MongoGeocodeDAO.count(MongoDBObject("hasPoly" -> true)) 17 18 val hasPolyCursor = 19 MongoGeocodeDAO.find(MongoDBObject("hasPoly" -> true)) 20 .sort(orderBy = MongoDBObject("_id" -> 1)) // sort by _id asc 31 toFindCovers: Map[Long, ObjectId] = group.filter(f => f.hasPoly).map(r => (r._id, r.polyId)).toMap 32 coverMap: Map[ObjectId, S2CoveringIndex] = S2CoveringIndexDAO.find(MongoDBObject("_id" -> MongoDBObject("$in" -> toFindCovers.values.toList))) 33 .toListGame.scala https://bitbucket.org/jmuthya/hangman.git | Scala | 117 lines
22 def create (id:Long, phrase_1: List[String], guesses_1 : List[Int], current_phrase : String, guesses_left:Int) { 23 val game = MongoDBObject("game_id" -> id, "phrase" -> MongoDBList(phrase_1), "guesses" -> MongoDBList(guesses_1), "current_phrase"->"", "current_guess"-> "_", "guesses_left" ->0, "letters_guessed"->"", "suggestions"->"") 24 mongoDB += game 32 def guess_letter(id:Long, letter: Char){ 33 val d = MongoDBObject("game_id"->id) 34 val cursor = models.MongoDBSetup.mongoDB.findOne(d).getOrElse(throw new Exception) 73 74 val d = MongoDBObject("game_id"->id) 75 val cursor = models.MongoDBSetup.mongoDB.findOne(d).getOrElse(throw new Exception) 82 val m = train_bigram_model(read_from_file("training/train.txt")) 83 val d = MongoDBObject("game_id"->id) 84 val cursor = models.MongoDBSetup.mongoDB.findOne(d) 93 def generate_random_phrase(id: Long) { 94 val d = MongoDBObject("game_id"->id) 95 val n = MongoDBObject("guesses_left"->100)OpLog.scala https://github.com/JanxSpirit/casbah.git | Scala | 142 lines
50 51 val cursor = oplog.find(q) 52 61 // Verify the oplog exists 62 val last = oplog.find().sort(MongoDBObject("$natural" -> 1)).limit(1) 63 assume(last.hasNext, 71 case Some(ts) => { 72 oplog.findOne(MongoDBObject("ts" -> ts)).orElse( 73 throw new Exception("No oplog entry for requested start timestamp.")) 82object MongoOpLogEntry { 83 def apply(entry: MongoDBObject) = entry("op") match { 84 case InsertOp => 132 133case class MongoUpdateOperation(timestamp: BSONTimestamp, opID: Long, namespace: String, document: MongoDBObject, documentID: MongoDBObject) extends MongoOpLogEntry { 134 val opType = UpdateOpQuery.scala https://github.com/josa/mongodb-scala-helper.git | Scala | 74 lines
4import collection.mutable.Builder 5import com.mongodb.casbah.commons.{Imports, MongoDBObject} 6import org.slf4j.LoggerFactory 16 17 val queryBuilder = MongoDBObject.newBuilder 18 22 val listBuilder: Builder[Document, List[Document]] = List.newBuilder[Document] 23 val cursor: DBCursor = collection.find(queryBuilder.result) 24 while (cursor.hasNext) listBuilder += DocumentTools.fromMongoObject(cursor.next, documentClass) 27 case true => 28 logger.debug("find %s query[%s], %s itens encontrados".format(documentClass.getSimpleName, cursor.getQuery.toString, cursor.size)) 29 list.size match { 45 val dbObject: Imports.DBObject = queryBuilder.result 46 val entity = DocumentTools.fromMongoObject(collection.findOne(dbObject), documentClass) 47 logger.isDebugEnabled() match {SimpleWebapp.scala https://github.com/JanxSpirit/mongosv_scalatra_casbah.git | Scala | 67 lines
33 post("/msgs") { 34 val builder = MongoDBObject.newBuilder 35 builder += "author" -> params("author") 42 get("/msgs/:author") { 43 val builder = MongoDBObject.newBuilder 44 builder += "author" -> params("author") 44 builder += "author" -> params("author") 45 val res = coll.find(builder.result.asDBObject) 46 56 val inc = $inc("vote" -> 1) 57 coll.update(MongoDBObject("_id" -> new ObjectId(params("id"))), inc) 58 redirect("/msgs") 62 val inc = $inc("vote" -> -1) 63 coll.update(MongoDBObject("_id" -> new ObjectId(params("id"))), inc) 64 redirect("/msgs")MongoStorageBackend.scala https://github.com/ginkel/akka.git | Scala | 229 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 }Test.scala https://gitlab.com/dvolosnykh/education | Scala | 90 lines
25 val urls = List("a", "b", "d") 26 val query = MongoDBObject("crawler" -> "xxx") 27 mongoCollection.update(query, $addToSet("urls" ) $each urls, true, true) 33 34 val obj = mongoCollection.findOne(query).get 35 val count = obj.getAs[Int]("count").getMembersRegistry.scala https://gitlab.com/dvolosnykh/education | Scala | 106 lines
55 val strUrls = urls map { _.toString } 56 val query = MongoDBObject(MembersRegistry.ATTR_MEMBER -> member.toString) 57 collection.update(query, $addToSet(MembersRegistry.ATTR_URLS) $each strUrls, true, true) 59 60 val obj = collection.findOne(query).get 61 val count = obj.getAs[Int](MembersRegistry.ATTR_COUNT).getMongoCollection.scala https://github.com/marcello3d/casbah.git | Scala | 964 lines
73 /** 74 * find distinct values for a key 75 */ 78 /** 79 * find distinct values for a key 80 * @param query query to apply on collection 119 120 /** Find a collection that is prefixed with this collection's name. 121 * A typical use of this might be 128 * </pre></blockquote> 129 * @param n the name of the collection to find 130 * @return the matching collection 220 */ 221 def group[A <% DBObject : Manifest, B <% DBObject : Manifest](key: A, cond: B): Iterable[DBObject] = group(key, cond, MongoDBObject.empty, "function(obj, prev) {}") 222 def group[A <% DBObject : Manifest, B <% DBObject : Manifest](key: A, cond: B, function: String): Iterable[DBObject] = group(key, cond, MongoDBObject.empty, function)OutputHFile.scala https://gitlab.com/18runt88/twofishes | Scala | 65 lines
36 val hasPolyCursor = 37 MongoGeocodeDAO.find(MongoDBObject("hasPoly" -> true)) 38 hasPolyCursor.option = Bytes.QUERYOPTION_NOTIMEOUTMongoItem.scala https://github.com/alessandroleite/lojinha.git | Scala | 53 lines
3import com.mongodb.casbah.Imports._ 4import com.mongodb.casbah.commons.MongoDBObject 5import com.novus.salat.dao.SalatDAO 24 25 def findById(id: Int): Option[Item] = dao.findOne(MongoDBObject("_id" -> id)) 26 26 27 def all(): List[Item] = dao.find(MongoDBObject.empty).toList 28 28 29 def all(cat: String): List[Item] = dao.find(MongoDBObject("category" -> cat)).toList 30 41 42 def all(itemId: Int): List[Bid] = dao.find(MongoDBObject("item._id" -> itemId)).toList 43Template.scala https://gitlab.com/williamhogman/checklist.git | Scala | 98 lines
52 53 implicit object TemplateIsIdFindable extends IdFindable[Template] { 54 def byId(id: ObjectId) = { 54 def byId(id: ObjectId) = { 55 val query = MongoDBObject("_id" -> id) 56 val db = checklist.Database.db 75 val fields = MongoDBObject("templates" -> 1, "_id" -> 0) 76 db("users").findOne(MongoDBObject("username" -> username), fields) map { 77 _.getAsOrElse[Seq[ObjectId]]("templates", Seq[ObjectId]()) map (_.toString) 82 val col = db("templates") 83 val upd = MongoDBObject("$push" -> MongoDBObject("items" -> item.toMongoObject)) 84 objectIdQuery(id) map(col.update(_, upd)) 94 val col = db("templates") 95 val upd = MongoDBObject("$pull" -> MongoDBObject("items" -> MongoDBObject("id" -> itemid))) 96 objectIdQuery(id) map(col.update(_, upd))