async function example() {
  await client.connect();
  await client.execute(`CREATE KEYSPACE IF NOT EXISTS examples
                        WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1' }`);
  await client.execute(`USE examples`);
  await client.execute(`CREATE TABLE IF NOT EXISTS tbl_sample_kv (id uuid, value text, PRIMARY KEY (id))`);

  // The maximum amount of async executions that are going to be launched in parallel
  // at any given time
  const concurrencyLevel = 32;

  // Use an Array with 10000 different values
  const values = Array.from(new Array(10000).keys()).map(x => [ Uuid.random(), x.toString() ]);

  try {

    const query = 'INSERT INTO tbl_sample_kv (id, value) VALUES (?, ?)';
    await executeConcurrent(client, query, values);

    console.log(`Finished executing ${values.length} queries with a concurrency level of ${concurrencyLevel}.`);

  } finally {
    client.shutdown();
  }
}
async function example() {
  await client.connect();
  await client.execute(`CREATE KEYSPACE IF NOT EXISTS examples
                        WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1' }`);
  await client.execute(`USE examples`);
  await client.execute(`CREATE TABLE IF NOT EXISTS tbl_sample_kv (id uuid, value text, PRIMARY KEY (id))`);

  
  
  const concurrencyLevel = 32;

  
  const values = Array.from(new Array(10000).keys()).map(x => [ Uuid.random(), x.toString() ]);

  try {

    const query = 'INSERT INTO tbl_sample_kv (id, value) VALUES (?, ?)';
    await executeConcurrent(client, query, values);

    console.log(`Finished executing ${values.length} queries with a concurrency level of ${concurrencyLevel}.`);

  } finally {
    client.shutdown();
  }
}
async function example ( ) { await client . connect ( ) ; await client . execute ( ` ` ) ; await client . execute ( ` ` ) ; await client . execute ( ` ` ) ; // The maximum amount of async executions that are going to be launched in parallel // at any given time const concurrencyLevel = 32 ; // Use an Array with 10000 different values const values = Array . from ( new Array ( 10000 ) . keys ( ) ) . map ( x => [ Uuid . random ( ) , x . toString ( ) ] ) ; try { const query = 'INSERT INTO tbl_sample_kv (id, value) VALUES (?, ?)' ; await executeConcurrent ( client , query , values ) ; console . log ( ` ${ values . length } ${ concurrencyLevel } ` ) ; } finally { client . shutdown ( ) ; } }
Inserts multiple rows in a table from an Array using the built in method <code>executeConcurrent()</code>,
limiting the amount of parallel requests.
Inserts multiple rows in a table from an Array using the built in method <code > executeConcurrent () < / code > limiting the amount of parallel requests .