Package com.mongodb

Examples of com.mongodb.DBCursor.toArray()


        collection.insert(json("_id: 3"));
        collection.insert(json("_id: 4"));

        @SuppressWarnings("resource")
        DBCursor cursor = collection.find().limit(2).skip(2);
        assertThat(cursor.toArray()).containsExactly(json("_id: 3"), json("_id: 4"));
    }

    @Test
    public void testFindWithSkipLimitAfterDelete() {
        collection.insert(json("_id: 1"));
View Full Code Here


        collection.remove(json("_id: 1"));
        collection.remove(json("_id: 3"));

        @SuppressWarnings("resource")
        DBCursor cursor = collection.find().limit(2).skip(2);
        assertThat(cursor.toArray()).containsExactly(json("_id: 5"));
    }

    @Test
    public void testFullUpdateWithSameId() throws Exception {
        collection.insert(json("_id: 1"));
View Full Code Here

        collection.insert(json("_id: 1"));
        collection.insert(json("_id: 2"));

        @SuppressWarnings("resource")
        DBCursor cursor = collection.find(json("_id: {$in: [3,2,1]}"));
        assertThat(cursor.toArray()).containsExactly(json("_id: 1"), json("_id: 2"), json("_id: 3"));
    }

    @Test
    public void testIdNotAllowedToBeUpdated() {
        collection.insert(json("_id: 1"));
View Full Code Here

        collection.insert(json("a:3, _id:3"));
        collection.insert(json("a:4, _id:4"));

        @SuppressWarnings("resource")
        DBCursor cursor = collection.find().sort(json("a: -1"));
        assertThat(cursor.toArray()).containsExactly(json("a:4, _id:4"), json("a:3, _id:3"), json("a:2, _id:2"),
                json("a:1, _id:1"), json("_id: 5"));
    }

    @Test
    public void testSortByEmbeddedKey() {
View Full Code Here

        BasicDBObject fieldsToDrop = new BasicDBObject("members", 0);
        fieldsToDrop.put("communityAttributes", 0);
        fieldsToDrop.put("userAttributes", 0);
        DBCursor dbc = DbManager.getSocial().getCommunity().find(query, fieldsToDrop);
       
        List<DBObject> tmparray = dbc.toArray(); // (brings the entire thing into memory so don't get cursor timeouts)
        int i = 0;
        System.out.println("Initializing " + dbc.size() + " indexes:");
        for (int j = 0; j < 2; ++j) {
          for (DBObject dbotmp: tmparray) {
            if ((++i % 100) == 0) {
View Full Code Here

      }     
     
      DBCursor dbc = DbManager.getIngest().getSource().find(query, fields);
     
      // Remove communityids we don't want the user to see:
      if (bStrip && sanityCheckStrippedSources(dbc.toArray(), bAdmin)) {
        rp.setData(dbc.toArray(), (BasePojoApiMap<DBObject>)null);
      }
      else {
        rp.setData(SourcePojo.listFromDb(dbc, SourcePojo.listType()), new SourcePojoApiMap(userId, communityIdSet, ownedOrModeratedCommunityIdSet));
      }
View Full Code Here

     
      DBCursor dbc = DbManager.getIngest().getSource().find(query, fields);
     
      // Remove communityids we don't want the user to see:
      if (bStrip && sanityCheckStrippedSources(dbc.toArray(), bAdmin)) {
        rp.setData(dbc.toArray(), (BasePojoApiMap<DBObject>)null);
      }
      else {
        rp.setData(SourcePojo.listFromDb(dbc, SourcePojo.listType()), new SourcePojoApiMap(userId, communityIdSet, ownedOrModeratedCommunityIdSet));
      }
      rp.setResponse(new ResponseObject("Good Sources",true,"successfully returned good sources"));
View Full Code Here

        setStrippedFields(fields);
      }     
      DBCursor dbc = DbManager.getIngest().getSource().find(query, fields);     

      // Remove communityids we don't want the user to see:
      if (bStrip && sanityCheckStrippedSources(dbc.toArray(), bAdmin)) {
        rp.setData(dbc.toArray(), (BasePojoApiMap<DBObject>)null);
      }
      else {
        rp.setData(SourcePojo.listFromDb(dbc, SourcePojo.listType()), new SourcePojoApiMap(userId, communityIdSet, ownedOrModeratedCommunityIdSet));
      }
View Full Code Here

      }     
      DBCursor dbc = DbManager.getIngest().getSource().find(query, fields);     

      // Remove communityids we don't want the user to see:
      if (bStrip && sanityCheckStrippedSources(dbc.toArray(), bAdmin)) {
        rp.setData(dbc.toArray(), (BasePojoApiMap<DBObject>)null);
      }
      else {
        rp.setData(SourcePojo.listFromDb(dbc, SourcePojo.listType()), new SourcePojoApiMap(userId, communityIdSet, ownedOrModeratedCommunityIdSet));
      }
      rp.setResponse(new ResponseObject("Bad Sources",true,"Successfully returned bad sources"));
View Full Code Here

        setStrippedFields(fields);
      }     
      DBCursor dbc = DbManager.getIngest().getSource().find(query, fields);
     
      // Remove communityids we don't want the user to see:
      if (bStrip && sanityCheckStrippedSources(dbc.toArray(), bAdmin)) {
        rp.setData(dbc.toArray(), (BasePojoApiMap<DBObject>)null);
      }
      else {
        rp.setData(SourcePojo.listFromDb(dbc, SourcePojo.listType()), new SourcePojoApiMap(userId, communityIdSet, ownedOrModeratedCommunityIdSet));
      }
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.