Skip to content

Commit

Permalink
Cria índices antes de importar
Browse files Browse the repository at this point in the history
  • Loading branch information
Phenome committed Nov 29, 2023
1 parent 2a46b59 commit 814eba6
Showing 1 changed file with 32 additions and 32 deletions.
64 changes: 32 additions & 32 deletions src/ocorrencia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,38 @@ await client.connect(Deno.env.get('MONGO_URI') as string)
const iptsCol = client.database('dwc2json').collection('ipts')
const ocorrenciasCol = client.database('dwc2json').collection('ocorrencias')

console.log('Creating indexes')
await Promise.all([
ocorrenciasCol.createIndexes({
indexes: [
{
key: { scientificName: 1 },
name: 'scientificName'
},
{
key: { iptId: 1 },
name: 'iptId'
},
{
key: { ipt: 1 },
name: 'ipt'
}
]
}),
iptsCol.createIndexes({
indexes: [
{
key: { tag: 1 },
name: 'tag'
},
{
key: { ipt: 1 },
name: 'ipt'
}
]
})
])

type DbIpt = {
_id: Ipt['id']
tag: string
Expand Down Expand Up @@ -112,36 +144,4 @@ for (const { ipt: iptName, baseUrl, datasets } of iptSources) {
)
}
}

console.log('Creating indexes')
await Promise.all([
ocorrenciasCol.createIndexes({
indexes: [
{
key: { scientificName: 1 },
name: 'scientificName'
},
{
key: { iptId: 1 },
name: 'iptId'
},
{
key: { ipt: 1 },
name: 'ipt'
}
]
}),
iptsCol.createIndexes({
indexes: [
{
key: { tag: 1 },
name: 'tag'
},
{
key: { ipt: 1 },
name: 'ipt'
}
]
})
])
console.debug('Done')

0 comments on commit 814eba6

Please sign in to comment.