@Override
   protected void createStagingTable () throws Exception {
      this.getConnection();
      try {

         String sinkStagingCollectionName = getQualifiedStagingTableName();

         // create staging collection
         sinkDatabase.createCollection(sinkStagingCollectionName);

         // get primary keys, getting the unique indexes
         MongoCollection<Document> sinkCollection = sinkDatabase.getCollection(getSinkTableName());
         List<String> primaryKeys = new ArrayList<>();
         for (Document index : sinkCollection.listIndexes()) {
            if (index.get("unique") != null && (Boolean) index.get("unique")) {
               // get all key fields names
               Document key = (Document) index.get("key");
               for (String keyName : key.keySet()) {
                  primaryKeys.add(keyName);
               }
            }
         }

         setPrimaryKeys(primaryKeys);

         LOG.info("Creating staging collection : {}", sinkStagingCollectionName);

      } catch (Exception e) {
         LOG.error("Error creating staging table: {}", e.getMessage(), e);
         throw e;
      }
      this.close();
   }
Constructs the SqlManager.

@param opts the ReplicaDB ToolOptions describing the user's requested action.
src/main/java/org/replicadb/manager/MongoDBManager.java