Como comparar um valor com o seguinte em mongoDB

0 respostas
Spammer
Tenho uma lista de estudantes
{ "_id" : { "$oid" : "50906d7fa3c412bb040eb579"} , "student_id" : 0 , "type" : "homework" , "score" : 14.8504576811645}
{ "_id" : { "$oid" : "50906d7fa3c412bb040eb57a"} , "student_id" : 0 , "type" : "homework" , "score" : 63.98402553675503}
{ "_id" : { "$oid" : "50906d7fa3c412bb040eb57d"} , "student_id" : 1 , "type" : "homework" , "score" : 21.33260810416115}
{ "_id" : { "$oid" : "50906d7fa3c412bb040eb57e"} , "student_id" : 1 , "type" : "homework" , "score" : 44.31667452616328}
{ "_id" : { "$oid" : "50906d7fa3c412bb040eb581"} , "student_id" : 2 , "type" : "homework" , "score" : 60.9750047106029}
{ "_id" : { "$oid" : "50906d7fa3c412bb040eb582"} , "student_id" : 2 , "type" : "homework" , "score" : 97.75889721343528}
{ "_id" : { "$oid" : "50906d7fa3c412bb040eb585"} , "student_id" : 3 , "type" : "homework" , "score" : 50.81577033538815}
{ "_id" : { "$oid" : "50906d7fa3c412bb040eb586"} , "student_id" : 3 , "type" : "homework" , "score" : 92.71871597581605}
{ "_id" : { "$oid" : "50906d7fa3c412bb040eb589"} , "student_id" : 4 , "type" : "homework" , "score" : 5.244452510818443}
{ "_id" : { "$oid" : "50906d7fa3c412bb040eb58a"} , "student_id" : 4 , "type" : "homework" , "score" : 28.656451042441}
{ "_id" : { "$oid" : "50906d7fa3c412bb040eb58d"} , "student_id" : 5 , "type" : "homework" , "score" : 23.29430953857654}
{ "_id" : { "$oid" : "50906d7fa3c412bb040eb58e"} , "student_id" : 5 , "type" : "homework" , "score" : 41.21853026961924}
{ "_id" : { "$oid" : "50906d7fa3c412bb040eb591"} , "student_id" : 6 , "type" : "homework" , "score" : 81.23822046161325}
{ "_id" : { "$oid" : "50906d7fa3c412bb040eb592"} , "student_id" : 6 , "type" : "homework" , "score" : 89.72700715074382}

onde o student_id representa cada aluno cada aluno fez dois tarbalhos de casa valendo 100%, a minha intensao e comparar os 2 trabalhos de cada aluno e eliminar o com o menor valor

Abaixo esta o meu codigo
try {
			Mongo mongo = new Mongo("localhost");
													
			DB db = mongo.getDB("students"); 
												
			System.out.println("Connected to db --> " + db.getName());

			Set<String> collections = db.getCollectionNames(); 
																
																
			System.out.println("Collections found: " + collections.toString());
			DBCollection collection = db.getCollection("grades");
			System.out.println("Connected to: " + collection.toString());

			DBCursor cursor = collection.find();
			BasicDBObject query = new BasicDBObject();
			query.put("type", "homework");
			cursor = collection.find(query).sort(new BasicDBObject("student_id", 1));
			System.out.println(cursor.count());
			
			
			try{
				while(cursor.hasNext()){
					
					System.out.println(cursor.next());
					
				}
			}finally{
				cursor.close();
			}

		} catch (UnknownHostException e) {
			
			e.printStackTrace();
		}
Criado 9 de novembro de 2012
Respostas 0
Participantes 1