예제 #1
0
  public static void dropAllCollections() {
    // 本地、测试库
    SystemInitor.init(false, true);

    Set<String> collectionNames = MongoDbUtil.getAllCollectionNames(SystemInitor.getDbName());

    System.out.println(MongoDbUtil.getDbInfoWithCollSize(SystemInitor.getDbName()));

    DB db = MongoClientManager.getDb();

    for (String collName : collectionNames) {

      db.getCollection(collName).drop();

      System.out.println(collName + "---droped");
    }

    System.out.println("清理完毕后---------------------------------------");
    System.out.println(MongoDbUtil.getDbInfoWithCollSize(SystemInitor.getDbName()));
  }
예제 #2
0
  private static void getDbInfo() {
    SystemInitor.init(true, true);

    System.out.println(MongoDbUtil.getDbInfoWithCollSize(SystemInitor.getDbName()));
  }