https://github.com/nicmeister/mongodb-node
https://github.com/nicmeister/mongodb-node
Last synced: 11 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/nicmeister/mongodb-node
- Owner: NicmeisteR
- Created: 2020-01-16T21:14:24.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-01-19T17:42:17.000Z (over 6 years ago)
- Last Synced: 2025-07-19T20:27:38.226Z (about 1 year ago)
- Language: TypeScript
- Size: 30.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Node-TS-MongoDB
Node TypeScript Base with MongoDB.
# To-Do
| Task | Status | Endpoints
| ----------------------------------------------------- |:------: |:-------------:|
| Make an Express API that posts to MongoDB. | [✅] | /post |
| Make an Express API that gets data from MongoDB. | [✅] | /get |
| Make an Express API that deletes data from MongoDB. | [✅] | /delete |
| Make an Express API that updates data from MongoDB. | [✅] | /update |
| Add GraphQL. | [🚧] | /query |
# Notes
Insert:
* db.collection.insertOne() New in version 3.2
* db.collection.insertMany() New in version 3.2
Read:
* db.collection.find()
```javascript
db.users.find(
{ age: { $gt: 18 } },
{ name: 1, address: 1 }
).limit(5)
```
Update:
* db.collection.updateOne() New in version 3.2
* db.collection.updateMany() New in version 3.2
* db.collection.replaceOne() New in version 3.2
```javascript
db.users.updateMany(
{ age: { $lt: 18 } },
{ $set: { status: "reject" } }
)
```
Delete:
* db.collection.deleteOne() New in version 3.2
* db.collection.deleteMany() New in version 3.2
```javascript
db.users.deleteMany(
{ status: "reject" }
)
```
Reference:
* CRUD: https://docs.mongodb.com/manual/crud/
* Insert: https://docs.mongodb.com/manual/tutorial/insert-documents/
* Insert Methods: https://docs.mongodb.com/manual/reference/insert-methods/
* Query: https://docs.mongodb.com/manual/tutorial/query-documents/
* Update: https://docs.mongodb.com/manual/tutorial/update-documents/
* Delete: https://docs.mongodb.com/manual/tutorial/remove-documents/