Codota Logo
com.mongodb
Code IndexAdd Codota to your IDE (free)

How to use com.mongodb

Best Java code snippets using com.mongodb (Showing top 20 results out of 2,808)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
Dictionary d =
  • Codota Iconnew Hashtable()
  • Codota IconBundle bundle;bundle.getHeaders()
  • Codota Iconnew Properties()
  • Smart code suggestions by Codota
}
origin: Graylog2/graylog2-server

@Override
public long totalExtractorCount() {
  final DBObject query = new BasicDBObject(InputImpl.EMBEDDED_EXTRACTORS, new BasicDBObject("$exists", true));
  long extractorsCount = 0;
  try (DBCursor inputs = dbCollection.find(query, new BasicDBObject(InputImpl.EMBEDDED_EXTRACTORS, 1))) {
    for (DBObject input : inputs) {
      final BasicDBList extractors = (BasicDBList) input.get(InputImpl.EMBEDDED_EXTRACTORS);
      extractorsCount += extractors.size();
    }
  }
  return extractorsCount;
}
origin: prestodb/presto

public void shutdown()
{
  client.close();
}
origin: stackoverflow.com

 BasicDBObject doc = new BasicDBObject( "name", "Matt" );
collection.insert( doc );
ObjectId id = (ObjectId)doc.get( "_id" );
origin: Graylog2/graylog2-server

public BasicDBList getList(String key) {
  DBCollection coll = getCollection();
  DBObject query = new BasicDBObject();
  query.put("key", key);
  DBObject result = coll.findOne(query);
  return (BasicDBList) result.get("value");
}
origin: Graylog2/graylog2-server

@Override
public <T extends Persisted> int destroyAll(Class<T> modelClass) {
  return collection(modelClass).remove(new BasicDBObject()).getN();
}
origin: prestodb/presto

private MongoQueryRunner(Session session, int workers)
    throws Exception
{
  super(session, workers);
  server = new MongoServer(new SyncMemoryBackend());
  address = server.bind();
  client = new MongoClient(new ServerAddress(address));
}
origin: sqshq/piggymetrics

  @Override
  public DBObject convert(DataPointId id) {

    DBObject object = new BasicDBObject(FIELDS);

    object.put("date", id.getDate());
    object.put("account", id.getAccount());

    return object;
  }
}
origin: Graylog2/graylog2-server

protected <T extends Persisted> List<DBObject> query(Class<T> modelClass, DBObject query, DBObject sort, int limit, int offset) {
  return cursorToList(
      collection(modelClass)
          .find(query)
          .sort(sort)
          .limit(limit)
          .skip(offset)
  );
}
origin: Graylog2/graylog2-server

protected DBObject findOne(DBObject query, DBObject sort, String collectioName) {
  return collection(collectioName).findOne(query, new BasicDBObject(), sort);
}
origin: Graylog2/graylog2-server

@Override
public void doRun() {
  LOG.debug("Starting alarm callbacks migration");
  final DBObject selection = QueryBuilder.start("id").exists(true).get();
  final DBObject modifications = new BasicDBObject("$unset", new BasicDBObject("id", ""));
  this.dbCollection.updateMulti(selection, modifications);
  LOG.debug("Done with alarm callbacks migration");
}
origin: Graylog2/graylog2-server

public MongoClientURI getMongoClientURI() {
  final MongoClientOptions.Builder mongoClientOptionsBuilder = MongoClientOptions.builder()
      .connectionsPerHost(getMaxConnections())
      .threadsAllowedToBlockForConnectionMultiplier(getThreadsAllowedToBlockMultiplier());
  return new MongoClientURI(uri, mongoClientOptionsBuilder);
}
origin: Graylog2/graylog2-server

protected <T extends Persisted> List<DBObject> query(Class<T> modelClass, DBObject query, DBObject sort) {
  return cursorToList(collection(modelClass).find(query).sort(sort));
}
origin: looly/hutool

/**
 * 创建ServerAddress对象
 * 
 * @param host 主机域名或者IP(如果为空默认127.0.0.1)
 * @param port 端口(如果为空默认为)
 * @return ServerAddress
 */
private ServerAddress createServerAddress(String host, int port) {
  return new ServerAddress(host, port);
}
origin: looly/hutool

/**
 * 获得DB
 * 
 * @param dbName DB
 * @return DB
 */
public MongoDatabase getDb(String dbName) {
  return mongo.getDatabase(dbName);
}
origin: Graylog2/graylog2-server

protected <T extends Persisted> int destroyAll(Class<T> modelClass, DBObject query) {
  return collection(modelClass).remove(query).getN();
}
origin: Graylog2/graylog2-server

public boolean getBoolean(String key) {
  DBCollection coll = getCollection();
  
  DBObject query = new BasicDBObject();
  query.put("key", key);
  
  DBObject result = coll.findOne(query);
  if (result == null) {
    return false;
  }
  
  if (result.get("value").equals(true)) {
    return true;
  }
  
  return false;
}

origin: Graylog2/graylog2-server

protected int destroyAll(String collectionName) {
  return collection(collectionName).remove(new BasicDBObject()).getN();
}
origin: looly/hutool

/**
 * 创建ServerAddress对象
 * 
 * @param host 主机域名或者IP(如果为空默认127.0.0.1)
 * @param port 端口(如果为空默认为)
 * @return ServerAddress
 */
private ServerAddress createServerAddress(String host, int port) {
  return new ServerAddress(host, port);
}
origin: looly/hutool

/**
 * 获得DB
 * 
 * @param dbName DB
 * @return DB
 */
public MongoDatabase getDb(String dbName) {
  return mongo.getDatabase(dbName);
}
origin: apache/storm

/**
 * Closes all resources associated with this instance.
 */
public void close() {
  client.close();
}
com.mongodb

Most used classes

  • MongoClient
  • BasicDBObject
  • MongoDatabase
  • MongoCollection
  • ServerAddress
  • DBObject,
  • DBCollection,
  • FindIterable,
  • DBCursor,
  • MongoClientOptions$Builder,
  • MongoCredential,
  • MongoClientURI,
  • BasicDBList,
  • MongoClientOptions,
  • Filters,
  • Mongo,
  • JSON,
  • WriteResult,
  • MongoCursor
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now