Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/johnakhilomen/basic_mongo_operations
- Owner: johnakhilomen
- Created: 2021-07-28T06:06:19.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-03-04T17:17:57.000Z (10 months ago)
- Last Synced: 2024-03-04T19:07:25.360Z (10 months ago)
- Size: 16.6 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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
```