PageRenderTime 178ms queryFilters 1ms Sphinxql 31ms app.CodeModel.GetByIds 116ms findMatchingLines 14ms GetByIds 130ms meta 0ms repositoryFilters 13ms languageFilters 0ms sourceFilters 1ms

359 results for 'MongoDBObject find lang:Scala' (178 ms)

Source

Language

Repository

Application.scala https://github.com/a564941464/play_amz_list.git | Scala | 253 lines
24    
25    val query = MongoDBObject("login_name" -> login_name, "password" -> password)
26	
53    //print(user_id)
54    val query_user = MongoDBObject("_id" -> user_id)
55    val user  = DB.colls("User").findOne(query_user).get
57    if(user.get("is_super") == "true"){
58        product_list  = DB.colls(cagetory_name).find().sort(MongoDBObject("update_time" -> -1)).toList
59    }else{
60        val query_product = MongoDBObject("user_id" -> user_id)
61        product_list  = DB.colls(cagetory_name).find(query_product).sort(MongoDBObject("update_time" -> -1)).toList
62    }    
111	
112	var results = DB.colls(category_name).find(MongoDBObject("_id"->Map("$in"->product_ids)))
113	var file_content = get_CategoryMap(category_name).headline
SalatDAOSpec.scala https://github.com/kodemaniak/salat.git | Scala | 357 lines
184
185      val salatCursor = AlphaDAO.find(ref = MongoDBObject("_id" -> MongoDBObject("$gte" -> 2)))
186      salatCursor.next must_== alpha2
197      // works with limits!
198      val salatCursor3 = AlphaDAO.find(ref = MongoDBObject("_id" -> MongoDBObject("$gte" -> 2))).limit(2)
199      salatCursor3.next must_== alpha2
203      // works with limits and skip
204      val salatCursor4 = AlphaDAO.find(ref = MongoDBObject("_id" -> MongoDBObject("$gte" -> 2)))
205        .skip(2)
210      // works with limits and skip
211      val salatCursor5 = AlphaDAO.find(ref = MongoDBObject("_id" -> MongoDBObject("$gte" -> 2)))
212        .sort(orderBy = MongoDBObject("_id" -> -1)) // sort by _id desc
243    "support using an iterator" in new alphaContextWithData {
244      val results = AlphaDAO.find(ref = MongoDBObject("_id" -> MongoDBObject("$gte" -> 2)))
245        .sort(orderBy = MongoDBObject("_id" -> -1)) // sort by _id desc
SalatDAO.scala https://github.com/kodemaniak/salat.git | Scala | 523 lines
141    def parentIdsQuery(parentIds: List[ID]): DBObject = {
142      MongoDBObject(parentIdField -> MongoDBObject("$in" -> parentIds))
143    }
340  def ids[A <% DBObject](query: A): List[ID] = {
341    collection.find(decorateQuery(query), MongoDBObject("_id" -> 1)).map(_.expand[ID]("_id").get).toList
342  }
458  def primitiveProjection[P <: Any](query: DBObject, field: String)(implicit m: Manifest[P], ctx: Context): Option[P] = {
459    collection.findOne(decorateQuery(query), MongoDBObject(field -> 1)).flatMap {
460      dbo =>
472  def projections[P <: CaseClass](query: DBObject, field: String)(implicit m: Manifest[P], ctx: Context): List[P] =
473    collection.find(decorateQuery(query), MongoDBObject(field -> 1)).toList.flatMap {
474      r =>
485  def primitiveProjections[P <: Any](query: DBObject, field: String)(implicit m: Manifest[P], ctx: Context): List[P] = {
486    collection.find(query, MongoDBObject(field -> 1)).toList.flatMap(_.expand[P](field))
487  }
MongoItems.scala https://github.com/eddieliu/PredictionIO.git | Scala | 140 lines
40  def get(appid: Int, id: String) = {
41    itemColl.findOne(MongoDBObject("_id" -> idWithAppid(appid, id))) map { dbObjToItem(_) }
42  }
43
44  def getByAppid(appid: Int) = new MongoItemsIterator(itemColl.find(MongoDBObject("appid" -> appid)))
45
58
59    new MongoItemsIterator(itemColl.find(MongoDBObject("appid" -> appid, "lnglat" -> (nearSphereObj ++ maxDistObj))))
60  }
84  def getByIds(appid: Int, ids: Seq[String]) = {
85    itemColl.find(MongoDBObject("_id" -> MongoDBObject("$in" -> ids.map(idWithAppid(appid, _))))).toList map { dbObjToItem(_) }
86  }
88  def getRecentByIds(appid: Int, ids: Seq[String]) = {
89    itemColl.find(MongoDBObject("_id" -> MongoDBObject("$in" -> ids.map(idWithAppid(appid, _))))).sort(starttimeIndex).toList map { dbObjToItem(_) }
90  }
Settings04.scala https://github.com/eddieliu/PredictionIO.git | Scala | 242 lines
43    println("Looking for Engines without infoid...")
44    val engines = engineColl.find(MongoDBObject("infoid" -> MongoDBObject("$exists" -> false))).toList
45    if (engines.length > 0) {
50          engines map { engine =>
51            engineColl.update(MongoDBObject("_id" -> engine.as[Int]("_id")), MongoDBObject("$set" -> MongoDBObject("infoid" -> engine.as[String]("enginetype")), "$unset" -> MongoDBObject("enginetype" -> 1)))
52          }
127    println("Looking for OfflineEvals without iterations...")
128    val offlineEvalsWithoutIterations = offlineEvalColl.find(MongoDBObject("iterations" -> MongoDBObject("$exists" -> false)))
129
137            println(s"Update OfflineEval ID = $evalid with 'iterations'")
138            offlineEvalColl.update(MongoDBObject("_id" -> evalid), MongoDBObject("$set" -> MongoDBObject("iterations" -> 1)) )
139          }
212    println("Looking for Algo without status...")
213    val algoWithoutStatus = algoColl.find(MongoDBObject("status" -> MongoDBObject("$exists" -> false)))
214    if (algoWithoutStatus.length > 0) {
MongoAlgos.scala https://github.com/eddieliu/PredictionIO.git | Scala | 121 lines
70  def getByEngineid(engineid: Int) = new MongoAlgoIterator(
71    algoColl.find(MongoDBObject("engineid" -> engineid)).sort(MongoDBObject("name" -> 1))
72  )
74  def getDeployedByEngineid(engineid: Int) = new MongoAlgoIterator(
75    algoColl.find(MongoDBObject("engineid" -> engineid, "status" -> "deployed")).sort(MongoDBObject("name" -> 1))
76  )
78  def getByOfflineEvalid(evalid: Int, loop: Option[Int] = None, paramset: Option[Int] = None) = {
79    val q = MongoDBObject("offlineevalid" -> evalid) ++ loop.map(l => MongoDBObject("loop" -> l)).getOrElse(MongoUtils.emptyObj) ++ paramset.map(p => MongoDBObject("paramset" -> p)).getOrElse(MongoUtils.emptyObj)
80    new MongoAlgoIterator(algoColl.find(q).sort(MongoDBObject("name" -> 1)))
82
83  def getTuneSubjectByOfflineTuneid(tuneid: Int) = algoColl.findOne(MongoDBObject("offlinetuneid" -> tuneid, "loop" -> null, "paramset" -> null)) map { dbObjToAlgo(_) }
84
84
85  def getByIdAndEngineid(id: Int, engineid: Int): Option[Algo] = algoColl.findOne(MongoDBObject("_id" -> id, "engineid" -> engineid)) map { dbObjToAlgo(_) }
86
MongoU2IActions.scala https://github.com/eddieliu/PredictionIO.git | Scala | 66 lines
11class MongoU2IActions(db: MongoDB) extends U2IActions {
12  private val emptyObj = MongoDBObject()
13  private val u2iActionColl = db("u2iActions")
28
29  def getAllByAppid(appid: Int) = new MongoU2IActionIterator(u2iActionColl.find(MongoDBObject("appid" -> appid)))
30
31  def getAllByAppidAndUidAndIids(appid: Int, uid: String, iids: Seq[String]) = new MongoU2IActionIterator(
32    u2iActionColl.find(MongoDBObject("appid" -> appid, "uid" -> idWithAppid(appid, uid), "iid" -> MongoDBObject("$in" -> iids.map(idWithAppid(appid, _)))))
33  )
36    if (sortedByUid)
37      new MongoU2IActionIterator(u2iActionColl.find(MongoDBObject("appid" -> appid, "iid" -> idWithAppid(appid, iid))).sort(MongoDBObject("uid" -> 1)))
38    else
38    else
39      new MongoU2IActionIterator(u2iActionColl.find(MongoDBObject("appid" -> appid, "iid" -> idWithAppid(appid, iid))))
40  }
MongoOfflineEvals.scala https://github.com/eddieliu/PredictionIO.git | Scala | 107 lines
10
11  private val emptyObj = MongoDBObject()
12  private val offlineEvalColl = db("offlineEvals")
70    // NOTE: _id field is always returned although it is not specified in getFields.
71    offlineEvalColl.findOne(MongoDBObject("_id" -> id), getFields) map { dbObjToOfflineEval(_) }
72  }
76  def getByEngineid(engineid: Int): Iterator[OfflineEval] = new MongoOfflineEvalIterator(
77    offlineEvalColl.find(MongoDBObject("engineid" -> engineid), getFields).sort(MongoDBObject("name" -> 1))
78  )
80  def getByTuneid(tuneid: Int): Iterator[OfflineEval] = new MongoOfflineEvalIterator(
81    offlineEvalColl.find(MongoDBObject("tuneid" -> tuneid), getFields).sort(MongoDBObject("name" -> 1))
82  )
83
84  def getByIdAndEngineid(id: Int, engineid: Int): Option[OfflineEval] = offlineEvalColl.findOne(MongoDBObject("_id" -> id, "engineid" -> engineid)) map { dbObjToOfflineEval(_) }
85
Appdata.scala https://github.com/eddieliu/PredictionIO.git | Scala | 135 lines
46
47      val usersWithAttributes = usersColl.find(MongoDBObject("attributes" -> MongoDBObject("$exists" -> true)))
48      var userCount = 0
60      print("Updating item records with custom attributes...")
61      val itemsWithAttributes = itemsColl.find(MongoDBObject("attributes" -> MongoDBObject("$exists" -> true)))
62
93      print("Updating like actions to new action name (may take a while)...") 
94      val likeResult = u2iActionsColl.update(MongoDBObject("action" -> likeDislike, "v" -> 1), MongoDBObject("$set" -> MongoDBObject("action" -> "like"), "$unset" -> MongoDBObject("v" -> 1)), false, true)
95      checkWriteResult(likeResult)
97      print("Updating dislike actions to new action name (may take a while)...")
98      val dislikeResult = u2iActionsColl.update(MongoDBObject("action" -> likeDislike, "v" -> 0), MongoDBObject("$set" -> MongoDBObject("action" -> "dislike"), "$unset" -> MongoDBObject("v" -> 1)), false, true)
99      checkWriteResult(dislikeResult)
101      print("Updating view actions to new action name (may take a while)...")
102      val viewResult = u2iActionsColl.update(MongoDBObject("action" -> view), MongoDBObject("$set" -> MongoDBObject("action" -> "view")), false, true)
103      checkWriteResult(viewResult)
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)
package.scala https://gitlab.com/yqian1991/hellotest.git | Scala | 67 lines
27    val coll = db(dbName)
28    val a = MongoDBObject("hello" -> "world")
29    val b = MongoDBObject("language" -> "scala")
38  def getCursor(mongoClient: MongoClient, dbName:String): MongoCursor = {
39    val allDocs =  mongoClient(dbName)(dbName).find()
40    println( allDocs )
46    val coll = mongoClient(dbName)(dbName)
47    val query = MongoDBObject("hello" -> "world")
48    val update = MongoDBObject("platform" -> "iOS")
51    println("Number updated: " + result.getN)
52    for (c <- coll.find) println(c)
53  }
56    val coll = mongoClient(dbName)(dbName)
57    val query = MongoDBObject("language" -> "scala")
58    val result = coll.remove( query )
package.scala https://gitlab.com/yqian1991/ScalaHub.git | Scala | 63 lines
23    val coll = db(dbName)
24    val a = MongoDBObject("hello" -> "world")
25    val b = MongoDBObject("language" -> "scala")
34  def getCursor(mongoClient: MongoClient, dbName:String): MongoCursor = {
35    val allDocs =  mongoClient(dbName)(dbName).find()
36    println( allDocs )
42    val coll = mongoClient(dbName)(dbName)
43    val query = MongoDBObject("hello" -> "world")
44    val update = MongoDBObject("platform" -> "iOS")
47    println("Number updated: " + result.getN)
48    for (c <- coll.find) println(c)
49  }
52    val coll = mongoClient(dbName)(dbName)
53    val query = MongoDBObject("language" -> "scala")
54    val result = coll.remove( query )
MongoApps.scala https://github.com/eddieliu/PredictionIO.git | Scala | 89 lines
55
56  def getByUserid(userid: Int) = new MongoAppIterator(appColl.find(MongoDBObject("userid" -> userid), getFields))
57
59
60  def getByAppkeyAndUserid(appkey: String, userid: Int) = appColl.findOne(MongoDBObject("appkey" -> appkey, "userid" -> userid), getFields) map { dbObjToApp(_) }
61
61
62  def getByIdAndUserid(id: Int, userid: Int) = appColl.findOne(MongoDBObject("_id" -> id, "userid" -> userid), getFields) map { dbObjToApp(_) }
63
78  def updateAppkeyByAppkeyAndUserid(appkey: String, userid: Int, newAppkey: String) = {
79    appColl.findAndModify(MongoDBObject("appkey" -> appkey, "userid" -> userid), MongoDBObject("$set" -> MongoDBObject("appkey" -> newAppkey))) map { dbObjToApp(_) }
80  }
82  def updateTimezoneByAppkeyAndUserid(appkey: String, userid: Int, timezone: String) = {
83    appColl.findAndModify(MongoDBObject("appkey" -> appkey, "userid" -> userid), MongoDBObject("$set" -> MongoDBObject("timezone" -> timezone))) map { dbObjToApp(_) }
84  }
CasbahSuite.scala https://github.com/jwmatthews/scala_mongo_example.git | Scala | 85 lines
25    // Add the unique index to the collection
26    val index = MongoDBObject("id" -> 1)
27    val options = MongoDBObject("unique" -> true)
34    mongoColl += item1
35    assert(mongoColl.find().count === 1)
36
36
37    val builder2 = MongoDBObject.newBuilder
38    builder2 += "id" -> 2
61    // Approach #1 using a map on the Option
62    val found = mongoColl.findOne(MongoDBObject("id"->2))
63    assert(found != None)
66    // Approach #2 using a pattern match
67    mongoColl.findOne(MongoDBObject("id"->2)) match {
68      case None => assert(false == true)
MongoEngines.scala https://github.com/eddieliu/PredictionIO.git | Scala | 97 lines
66
67  def get(id: Int) = engineColl.findOne(MongoDBObject("_id" -> id)) map { dbObjToEngine(_) }
68
70
71  def getByAppid(appid: Int) = new MongoEngineIterator(engineColl.find(MongoDBObject("appid" -> appid)).sort(MongoDBObject("name" -> 1)))
72
72
73  def getByAppidAndName(appid: Int, name: String) = engineColl.findOne(MongoDBObject("appid" -> appid, "name" -> name)) map { dbObjToEngine(_) }
74
74
75  def getByIdAndAppid(id: Int, appid: Int): Option[Engine] = engineColl.findOne(MongoDBObject("_id" -> id, "appid" -> appid)) map { dbObjToEngine(_) }
76
95
96  def existsByAppidAndName(appid: Int, name: String) = engineColl.findOne(MongoDBObject("name" -> name, "appid" -> appid)) map { _ => true } getOrElse false
97}
MongoBox.scala git://github.com/trepidacious/boxes.git | Scala | 185 lines
12import boxes.util.WeakKeysBIDIMap
13import com.mongodb.casbah.commons.MongoDBObject
14import com.mongodb.MongoException
95  
96  def findById[T <: Node](id: ObjectId)(implicit man: Manifest[T]): Option[T] = findOne(MongoDBObject("_id" -> id))(man) 
97
97
98  def findOne[T <: Node](key: String, value: Any)(implicit man: Manifest[T]): Option[T] = findOne(MongoDBObject(key -> value))(man)
99    
99    
100  def findOne[T <: Node](query: MongoDBObject)(implicit man: Manifest[T]): Option[T] = {
101    Box.transact {
109  
110  def find[T <: Node](query: MongoDBObject)(implicit man: Manifest[T]): Iterator[T] = {
111    Box.transact {
UrlShortener.scala https://github.com/ufholdpig/hstest.git | Scala | 154 lines
69                   //co.update( MongoDBObject("shortUrl" -> s), 
70                   //           MongoDBObject("$set" -> MongoDBObject("count" -> n))
71                   //         )
72                   //------------------------------------------------------------------
73        		   // Use findAndModify to increase count field to avoid parallel issue
74                   //------------------------------------------------------------------
74                   //------------------------------------------------------------------
75                   co.findAndModify(query =  MongoDBObject("shortUrl" -> s),
76                                    update = $inc("count" -> 1)
95      case "ALL"               => null
96      case x if(x.length == 6) => MongoDBObject("shortUrl" -> s)
97      case _                   => MongoDBObject("longUrl" -> s)
98    }
99    //"[%s]".format(co.find(query,MongoDBObject("_id" -> 0)).toList.mkString(","))
100    co.find(query,MongoDBObject("_id" -> 0)).toList.mkString(",")
MongoAlgoInfos.scala https://github.com/eddieliu/PredictionIO.git | Scala | 74 lines
29    // required fields
30    val obj = MongoDBObject(
31      "_id" -> algoInfo.id,
43    val batchcommandsObj = algoInfo.batchcommands.map { c => MongoDBObject("batchcommands" -> c) } getOrElse MongoUtils.emptyObj
44    val offlineevalcommandsObj = algoInfo.offlineevalcommands.map { c => MongoDBObject("offlineevalcommands" -> c) } getOrElse MongoUtils.emptyObj
45
48
49  def get(id: String) = coll.findOne(MongoDBObject("_id" -> id)) map { dbObjToAlgoInfo(_) }
50
50
51  def getAll() = coll.find().toSeq map { dbObjToAlgoInfo(_) }
52
52
53  def getByEngineInfoId(engineinfoid: String) = coll.find(MongoDBObject("engineinfoid" -> engineinfoid)).sort(MongoDBObject("_id" -> 1)).toSeq map { dbObjToAlgoInfo(_) }
54
MongoOfflineTunes.scala https://github.com/eddieliu/PredictionIO.git | Scala | 91 lines
10
11  private val emptyObj = MongoDBObject()
12  private val offlineTuneColl = db("offlineTunes")
50    // optional fields
51    val createtimeObj = offlineTune.createtime.map(x => MongoDBObject("createtime" -> x)).getOrElse(emptyObj)
52    val starttimeObj = offlineTune.starttime.map(x => MongoDBObject("starttime" -> x)).getOrElse(emptyObj)
52    val starttimeObj = offlineTune.starttime.map(x => MongoDBObject("starttime" -> x)).getOrElse(emptyObj)
53    val endtimeObj = offlineTune.endtime.map(x => MongoDBObject("endtime" -> x)).getOrElse(emptyObj)
54
62  def get(id: Int): Option[OfflineTune] = {
63    offlineTuneColl.findOne(MongoDBObject("_id" -> id), getFields) map { dbObjToOfflineTune(_) }
64  }
67
68  def getByEngineid(engineid: Int): Iterator[OfflineTune] = new MongoOfflineTuneIterator(offlineTuneColl.find(MongoDBObject("engineid" -> engineid), getFields))
69
UserManager.scala https://github.com/a564941464/play_amz_list.git | Scala | 94 lines
20    val post_map = request.body.asFormUrlEncoded.get // Map[String, List]
21    val query = MongoDBObject("_id" -> user_id)
22    
22    
23	var update = MongoDBObject("is_super"->"false")    
24    
38   def edit_user(user_id: String) = Action {request=>
39    val query = MongoDBObject("_id" -> user_id)
40	val user = DB.colls("User").findOne(query).get
44  def del_user_act(user_id: String) = Action{ implicit request =>
45	  val query = MongoDBObject("_id" -> user_id)
46	  val result = DB.colls("User").remove(query)
76    val user_id = request.session.get("user_id").get
77    val query_user = MongoDBObject("_id" -> user_id)
78    val user  = DB.colls("User").findOne(query_user).get
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18