当前位置: 动力学知识库 > 问答 > 编程问答 >

java - Clear OrientDB database

问题描述:

Given a com.orientechnologies.orient.core.db.ODatabase<T> object, what's the best way to clear the database (that's erase each and every object but respect the existing schema)?

网友答案:

Based on Alessandro's comment and rmuller's answer to this question, I've built a java helper method.

db.getMetadata().getSchema().getClasses().stream()
     .filter(oClass -> !oClass.getName().startsWith(ORIENTDB_CLASS_PREFIX)) //
     .forEach(oClass -> {
          try {
              oClass.truncate();
          } catch (IOException e) {
              LOGGER.warn("Not possible to truncate class " + oClass.getName(), e);
          }
     });
分享给朋友:
您可能感兴趣的文章:
随机阅读: