Package com.mongodb

Examples of com.mongodb.DBCollection.distinct()


        DBCollection collection = writeClient.getDB("testdb").getCollection("testcollection");
        collection.insert(new BasicDBObject("n", 1));
        collection.insert(new BasicDBObject("n", 2));
        collection.insert(new BasicDBObject("n", 1));
        collection = readOnlyClient.getDB("testdb").getCollection("testcollection");
        assertThat(collection.distinct("n")).containsExactly(1, 2);
    }

    @Test
    public void testInsert() throws Exception {
        DBCollection collection = readOnlyClient.getDB("testdb").getCollection("testcollection");
View Full Code Here


            {
                DBCollection dbc = db.getCollection( s );
                log.info( "getLayers; collection=" + dbc );
                // find distinct non-null geometry to determine if valid layer
                // TODO branch point for separate geometry-specific layers per collection
                List geoList = dbc.distinct( "geometry.type" );
                // distinct returns single BSON List, may barf if results large, > max doc. size
                // trap exception on props distinct and assume it's valid since there's obviously
                // something there (http://www.mongodb.org/display/DOCS/Aggregation)
                List propList = null;
                try
View Full Code Here

                // trap exception on props distinct and assume it's valid since there's obviously
                // something there (http://www.mongodb.org/display/DOCS/Aggregation)
                List propList = null;
                try
                {
                    propList = dbc.distinct( "properties" );
                }
                catch (IllegalArgumentException ex)
                {
                    propList = new BasicBSONList();
                    propList.add( "ex nihilo" );
View Full Code Here

  @SuppressWarnings("unchecked")
  public List<Object> distinct(String field) {
    assertValid();
    DBCollection col = db.getCollection(collection);
    return (readPreference!=null)
      ? col.distinct(field, toQueryObject(objectMapper), readPreference)
      : col.distinct(field, toQueryObject(objectMapper));
  }

  /**
   * Returns distinct values for the given field.  This field
View Full Code Here

  public List<Object> distinct(String field) {
    assertValid();
    DBCollection col = db.getCollection(collection);
    return (readPreference!=null)
      ? col.distinct(field, toQueryObject(objectMapper), readPreference)
      : col.distinct(field, toQueryObject(objectMapper));
  }

  /**
   * Returns distinct values for the given field.  This field
   * passed must be the name of a field on a MongoDB document.
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.