27
loading...
This website collects cookies to deliver better user experience
A equipe estratégica da montadora deseja criar um relatório contendo todas as vendas feitas no mês de agosto de 2020 tanto pela concessionária quanto direto pela fábrica.
O sistema da montadora divide essas vendas em duas collections do mongo.
O relatório é gerado por uma ferramenta consolidada de mercado que aceita a importação dos dados por arquivos .csv ou .json
#$> mongoexport mongodb://localhost:27017 --db examples #comando executado
2021-08-26T08:39:03.607-0300 must specify a collection
2021-08-26T08:39:03.615-0300 try 'mongoexport --help' for more information
mongosh mongodb://localhost:27017
> load('export_data_multiple_databases/obter_vendas.js')
mongosh mongodb://localhost:27017/examples ~/export_data_multiple_databases/obter_vendas.js
Current Mongosh Log ID: 612918a2e3f888785924e0e9
Connecting to: mongodb://localhost:27017/examples?directConnection=true&serverSelectionTimeoutMS=2000
Using MongoDB: 5.0.0
Using Mongosh Beta: 0.14.0
For mongosh info see: https://docs.mongodb.com/mongodb-shell/
------
The server generated these startup warnings when booting:
2021-08-27T10:16:56.220+00:00: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine. See http://dochub.mongodb.org/core/prodnotes-filesystem
2021-08-27T10:16:56.525+00:00: Access control is not enabled for the database. Read and write access to data and configuration is unrestricted
2021-08-27T10:16:56.526+00:00: /sys/kernel/mm/transparent_hugepage/enabled is 'always'. We suggest setting it to 'never'
------
> load('~/export_data_multiple_databases/obter_vendas.js')
[{
fabricante: 'Lexus',
modelo: 'LS',
ano: 2004,
datavenda: ISODate("2021-08-03T00:00:00.000Z"),
preco: '$106375.36',
collectionName: 'vendas_concessionaria'
},
{
fabricante: 'GMC',
...
Importante ressaltar que o script importado fica disponível somente naquela sessão.
mongosh mongodb://localhost:27017/examples ~/export_data_multiple_databases/obter_vendas.js > arquivo_resultado.json
mongosh mongodb://localhost:27017/examples --eval="load('export_data_multiple_databases/obter_massa_dados.js');"
mongosh mongodb://localhost:27017/examples --eval="load('export_data_multiple_databases/obter_massa_dados.js');" > arquivo_resultado.json
Current Mongosh Log ID: 6129153e30afffaa9fb76fe4
Connecting to: mongodb://localhost:27017/examples?directConnection=true&serverSelectionTimeoutMS=2000
Using MongoDB: 5.0.0
Using Mongosh Beta: 0.14.0
For mongosh info see: [1mhttps://docs.mongodb.com/mongodb-shell/]
-----------
The server generated these startup warnings when booting:
2021-08-27T10:16:56.220+00:00: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine. See http://dochub.mongodb.org/core/prodnotes-filesystem
2021-08-27T10:16:56.525+00:00: Access control is not enabled for the database. Read and write access to data and configuration is unrestricted
2021-08-27T10:16:56.526+00:00: /sys/kernel/mm/transparent_hugepage/enabled is 'always'. We suggest setting it to 'never'
-----------
Loading file: ~\export_data_multiple_databases\obter_vendas.js
[{
fabricante: 'Hyundai',
modelo: 'Genesis',
ano: 2009,
...
mongosh mongodb://localhost:27017/examples --quiet ~/export_data_multiple_databases/obter_massa_dados.js > arquivo_resultado.json
mongosh mongodb://localhost:27017/examples --quiet --eval="load('export_data_multiple_databases/obter_massa_dados.js');" > arquivo_resultado.json