public void createMongoDBCollection ( String colectionName , DataTable options ) { BasicDBObject aux = new BasicDBObject ( ) ; // Recorremos las options para castearlas y añadirlas a la collection List < List < String > > rowsOp = options . raw ( ) ; for ( int i = 0 ; i < rowsOp . size ( ) ; i ++ ) { List < String > rowOp = rowsOp . get ( i ) ; if ( rowOp . get ( 0 ) . equals ( "size" ) || rowOp . get ( 0 ) . equals ( "max" ) ) { int intproperty = Integer . parseInt ( rowOp . get ( 1 ) ) ; aux . append ( rowOp . get ( 0 ) , intproperty ) ; } else { Boolean boolProperty = Boolean . parseBoolean ( rowOp . get ( 1 ) ) ; aux . append ( rowOp . get ( 0 ) , boolProperty ) ; } } dataBase . createCollection ( colectionName , aux ) ; }
Create a MongoDB collection .