Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/johnakhilomen/basic_mongo_operations

JSON data
https://github.com/johnakhilomen/basic_mongo_operations

Last synced: about 1 month ago
JSON representation

JSON data

Awesome Lists containing this project

README

        

# json_data
JSON data

***Create Database***
```python
use moviedb
```

# import json data
```python
mongoimport --db moviedb --collection movies --file /Users/user1/Downloads/json_data-main/movies.json
mongoimport --db moviedb --collection users --file /Users/user1/Downloads/json_data-main/users.json
```
# Get all
```python
db.movies.find();
```

# Get one
```python
db.users.findOne({Username: "jondoe2"});
```

# Drop collection:
```python
db.movies.drop()
```

# Update collection
```python
db.users.updateOne({Username: "jondoe2"}, {$set: {Email: "[email protected]", Password: "newpasscode1"} } )
```

# Delete one
```python
db.users.remove({Username: "jondoe2"});
```

# Get sub object
```python
db.movies.find({"Genre.Name": "Thriller"})
```
## Mongo import for remote db
```python
mongoimport --uri mongodb+srv://readnwriteuser:[email protected]/myFirstDatabase --collection movies --file /Users/johnakhilomen/Downloads/json_data-main/movies.json --type json
```

## Mongo Export to json file
```python
mongoexport --uri mongodb://localhost:27017/myFlixdb --collection movies --type json -o db.json
```