File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -12,15 +12,16 @@ const collection = client.database('dwc2json').collection('ocorrencias')
12
12
console . debug ( 'Cleaning collection' )
13
13
console . log ( await collection . deleteMany ( { } ) )
14
14
15
+ const CHUNK_SIZE = 50000 ;
15
16
for ( const url of refUrls ) {
16
17
if ( ! url ) continue
17
18
console . debug ( `Processing ${ url } ` )
18
19
const json = await processaZip ( url )
19
20
const ocorrencias = Object . values ( json )
20
21
console . debug ( `Inserting entries (${ ocorrencias . length } )` )
21
- for ( let i = 0 , n = ocorrencias . length ; i < n ; i += 5000 ) {
22
- console . log ( `Inserting ${ i } to ${ Math . min ( i + 5000 , n ) } ` )
23
- await collection . insertMany ( ocorrencias . slice ( i , i + 5000 ) , {
22
+ for ( let i = 0 , n = ocorrencias . length ; i < n ; i += CHUNK_SIZE ) {
23
+ console . log ( `Inserting ${ i } to ${ Math . min ( i + CHUNK_SIZE , n ) } ` )
24
+ await collection . insertMany ( ocorrencias . slice ( i , i + CHUNK_SIZE ) , {
24
25
ordered : false
25
26
} )
26
27
}
You can’t perform that action at this time.
0 commit comments