Search
 
SCRIPT & CODE EXAMPLE
 

CSS

insert millions of records mongodb

import { MongoClient } from 'mongodb';
const url = 'mongodb://mongo:27017';

const client = new MongoClient(url);

const test = async (start, end) => {
  const array = [...Array(end - start + 1).keys()].map(x => x + start);
  const obj = array.map(id => {
    return [1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map(cid => {
      return { id, cid, pid: [1, 2, 3, 4, 5, 6, 7, 8, 9, 0] }
    });
  });
  await client.connect();

  await client.db('test2').collection('test').insertMany(obj.flat());
}

const testAsCunck = async (chunk) => {
  for (let inx = 0; inx < 1000; inx++) {
    console.log(inx*chunk+1, (inx*chunk+chunk));
    const start = inx*chunk+1;
    const end = inx*chunk+chunk;
    await test(start, end);
  }
}

//insert 10million records 
testAsCunck(10000);
Comment

PREVIOUS NEXT
Code Example
Css :: felx-wrap css 
Css :: blur on scroll css 
Css :: 0 
Css :: gastby tailwind css 
Css :: Tooltip animation effect 
Css :: navbar link goes down more than expected 
Css :: div with no content have a width/height 
Css :: CSS style all div elements 
Css :: two file css how to get one 
Css :: grape change status code 
Css :: cliping setting 
Css :: gulp association of files 
Css :: fond de couleur noir et texte en blanc css 
Css :: add css to javafx fxml 
Css :: responsive header with logo and menu css code 
Css :: transition all except one property 
Css :: prevenrt div with height 100% from growing up 
Css :: hwo to reload css in flask 
Css :: edit default theme in component angular css 
Css :: how to override bootstrap css in wordpress 
Css :: how to add css to emelemt with add_actions 
Css :: css on field blank red border 
Css :: The CSS to make all the columns equal in width is as follows 
Css :: after 50% not center 
Css :: button expo css 
Css :: if navbar items not shown on responsive page 
Css :: css background-clip 
Css :: css garden 
Typescript :: how to remove dots in ul li 
Typescript :: react children 
ADD CONTENT
Topic
Content
Source link
Name
6+5 =