https://github.com/antoniocaccamo/poc-mongodb
https://github.com/antoniocaccamo/poc-mongodb
micronaut-cli mongodb
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/antoniocaccamo/poc-mongodb
- Owner: antoniocaccamo
- Created: 2019-09-23T10:41:04.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-06-22T20:06:06.000Z (almost 4 years ago)
- Last Synced: 2025-07-30T07:40:40.890Z (10 months ago)
- Topics: micronaut-cli, mongodb
- Language: Python
- Homepage:
- Size: 1.79 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# poc-mongo
```bash
# set env vars
$ for x in $(awk '/MONGO/ { print $1 }' .env); do export $x; done;
$ docker run --name mongo-srv -v ${MONGODB_DATA}:/data/db \
-p 27017:27017 -d mongo
$ docker exec -it mongo-srv bash
$ mongo
> db
test
> use learning_mongo
switched to db learning_mongo
> show dbs
admin 0.000GB
config 0.000GB
local 0.000GB
> db.cars.insert({"vendor":"subaru"})
WriteResult({ "nInserted" : 1 })
> show dbs
admin 0.000GB
config 0.000GB
learning_mongo 0.000GB
local 0.000GB
> for ( i=0; i < 10000; i++) { db.numbers.insert({"nbr":i}) }
WriteResult({ "nInserted" : 1 })
> db.numbers.find({"nbr": 400})
{ "_id" : ObjectId("5d8884babe46e369e6675d2c"), "nbr" : 400 }
> db.numbers.find({"nbr": 400}).execution()
> db.numbers.find({"nbr": 400}).explain("executionStats")
> db.numbers.createIndex({nbr:1})
> db.numbers.find({"nbr": 400}).explain("executionStats")
```
## import
```bash
$ mongoimport -d learning_monogo -c tours --jsonArray --file
[Ex_Files_Learning_MongoDB/Exercise Files/Chapter2/02_02/Start/tours.json](Ex_Files_Learning_MongoDB/Exercise Files/Chapter2/02_02/Start/tours.json)
2019-09-23T09:05:08.057+0000 connected to: mongodb://localhost/
2019-09-23T09:05:08.090+0000 29 document(s) imported successfully. 0 document(s) failed to import.
$ mongo
> use learning_mongo
switched to db learning_mongo
> show collections
cars
tours
> db.tours.count()
29
> db.tours.find({"tourTags" : "hiking"})
```