https://github.com/kevinmichaelchen/express-mongoose-example
Simple CRUD app with NodeJS, Express, Mongoose, MongoDB, ES6
https://github.com/kevinmichaelchen/express-mongoose-example
express express-js mean mongodb mongoose nodejs
Last synced: 3 months ago
JSON representation
Simple CRUD app with NodeJS, Express, Mongoose, MongoDB, ES6
- Host: GitHub
- URL: https://github.com/kevinmichaelchen/express-mongoose-example
- Owner: kevinmichaelchen
- Created: 2021-02-10T17:03:50.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-02-20T19:11:01.000Z (about 4 years ago)
- Last Synced: 2025-02-23T22:43:39.112Z (3 months ago)
- Topics: express, express-js, mean, mongodb, mongoose, nodejs
- Language: JavaScript
- Homepage: https://github.com/kevinmichaelchen/express-mongoose-example/projects/1
- Size: 392 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# express-mongoose-example
Learning how to build an API with the NodeJS, Express, MongoDB, Mongoose stack.
## Getting started
### Running MongoDB in Docker
```
sudo docker run -it --rm -v $HOME/mongodata:/data/db --name mongodb -p 27017:27017 -d mongo
```### Running the app
```
npm start
```### Hitting the API
#### Create document
```bash
http POST localhost:3000/steps title="Woo"
```#### Update document
```bash
http PUT localhost:3000/steps/{DOCUMENT_ID} title="New Title"
```#### Get single document
```bash
http GET localhost:3000/steps/{DOCUMENT_ID}
```#### Get all documents
```bash
http GET localhost:3000/steps# Forward pagination
http GET localhost:3000/steps first=="2" after=="01EY6YXJMWSJTG5QD1D866XACY"# Backward pagination
http GET localhost:3000/steps last=="2" before=="01EY6YXJMWSJTG5QD1D866XACY"
```#### Delete document
```bash
http DELETE localhost:3000/steps/{DOCUMENT_ID}
```#### Delete all documents
```bash
http DELETE localhost:3000/steps
```## Sources
- [Converting to ES6](https://www.freecodecamp.org/news/how-to-enable-es6-and-beyond-syntax-with-node-and-express-68d3e11fe1ab/)
- [Using async/await with Express](https://zellwk.com/blog/async-await-express/)
- [Limiting results](https://kb.objectrocket.com/mongo-db/how-to-use-the-mongoose-limit-function-927)
- [ULID](https://github.com/ulid/spec), a compact, random ID generator with sorting.