Package com.mongodb

Examples of com.mongodb.DBCollection.find()


  }

  public java.util.List<DBObject> LastMessages() {
    DBCollection messagesCollection = chatDatabase.getCollection("historymessages");
    java.util.List<DBObject> messages = messagesCollection.find().toArray();

    for (int i = 0; i < messages.size(); i++) {
      System.out.println(messages.get(i));
    }
View Full Code Here


  }

  @Override
  public List<Message> getLastMessages() {
    DBCollection messagesCollection = chatDatabase.getCollection("historymessages");
    DBCursor curs = messagesCollection.find();

    List<Message> messages = new ArrayList<>();
    while (curs.hasNext()) {
      DBObject o = curs.next();
      String test = o.get("message").toString();
View Full Code Here

  public void onlyTenMessages() {
    DBCollection messagesCollection = chatDatabase.getCollection("historymessages");
    long nbMessages = messagesCollection.count();
    while (nbMessages > 10) {
      // enregistrement le plus vieux
      DBCursor oldestMessage = messagesCollection.find().sort(new BasicDBObject("date", 1)).limit(1);
      messagesCollection.remove(oldestMessage.next());
      nbMessages = messagesCollection.count();
    }

  }
View Full Code Here

    MessagesHistoryMongo conect = new MessagesHistoryMongo();

    DBCollection messagesCollection = chatDatabase.getCollection("historymessages");
   
    Long numberOfMessages = messagesCollection.count();
    DBCursor curs = messagesCollection.find();
    List<Message> messages = new ArrayList<>();
    while (curs.hasNext()) {
      DBObject o = curs.next();
      String test=o.get("message").toString();
      Gson gson = new Gson();
View Full Code Here

    conect.saveMessage(message11);
    Long numberOfMessagesNew = messagesCollection.count();
    Assert.assertEquals(new Long(10), numberOfMessagesNew);
   
    DBCursor cursNew = messagesCollection.find();
    List<Message> messagesNew = new ArrayList<>();
    while (cursNew.hasNext()) {
      DBObject o = cursNew.next();
      String objectMessageNew=o.get("message").toString();
      Gson gson = new Gson();
View Full Code Here

        23, 45, 432, 7765, 432, 75, 213, 6543, 432, 7576, 1321, 6546, 4234, 657, 42132, 675, 432, 654, 4232,
        543 });
    // 根据userId in('10010171','10010172')查询
    DBObject in_query = new BasicDBObject();
    in_query.put("actionerId", in_data);
    DBCursor inQueryResult = collection.find(in_query);
    // System.out.println("按in条件查询结果:");
    for (Iterator<DBObject> iter = inQueryResult.iterator(); iter.hasNext();) {
      // System.out.println(iter.next());
      iter.next();
    }
View Full Code Here

     * @param jobExecutionId if null, retrieves all StepExecutions; otherwise, retrieves all StepExecutions belongs to the JobExecution id
     * @return a list of StepExecutions
     */
    List<StepExecution> selectStepExecutions(final Long jobExecutionId) {
        final DBCollection collection = db.getCollection(TableColumns.STEP_EXECUTION);
        DBCursor cursor = jobExecutionId == null ? collection.find() :
                collection.find(new BasicDBObject(TableColumns.JOBEXECUTIONID, jobExecutionId));
        cursor = cursor.sort(new BasicDBObject(TableColumns.STEPEXECUTIONID, 1));
        final List<StepExecution> result = new ArrayList<StepExecution>();
        createStepExecutionsFromDBCursor(cursor, result);
        return result;
View Full Code Here

     * @return a list of StepExecutions
     */
    List<StepExecution> selectStepExecutions(final Long jobExecutionId) {
        final DBCollection collection = db.getCollection(TableColumns.STEP_EXECUTION);
        DBCursor cursor = jobExecutionId == null ? collection.find() :
                collection.find(new BasicDBObject(TableColumns.JOBEXECUTIONID, jobExecutionId));
        cursor = cursor.sort(new BasicDBObject(TableColumns.STEPEXECUTIONID, 1));
        final List<StepExecution> result = new ArrayList<StepExecution>();
        createStepExecutionsFromDBCursor(cursor, result);
        return result;
    }
View Full Code Here

      BasicDBObject fields = new BasicDBObject();
      fields.put("_id", -1);
      fields.append("k", 1);
      fields.append("v", 1);
      if (batchSize != null)
        cursor = dbCollection.find(query, fields).batchSize(batchSize);
      else
        cursor = dbCollection.find(query, fields);

      if (batchListener != null)
        batchListener.afterFetchingNextBatch(cursor.count());
View Full Code Here

      fields.append("k", 1);
      fields.append("v", 1);
      if (batchSize != null)
        cursor = dbCollection.find(query, fields).batchSize(batchSize);
      else
        cursor = dbCollection.find(query, fields);

      if (batchListener != null)
        batchListener.afterFetchingNextBatch(cursor.count());
     
      List<DBObject> finalRes = new ArrayList<DBObject>();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.