|
|
|
|
|
by spaceman_2020
1287 days ago
|
|
I've been using it for small blocks of code or specific functions - stuff I'd have to look up documentation or Stackoverflow for. I see it as a productivity booster, not a replacement. You can't tell it to "create a CRUD app", but you can ask it to create a nodejs function that gets all the records from a mongodb database. |
|
const express = require('express')
const app = express()
// define the model for a user
const User = {
}// create a new user
app.post('/users', (req, res) => {
})// read a list of users
app.get('/users', (req, res) => {
})// read a single user
app.get('/users/:id', (req, res) => {
})// update a user
app.put('/users/:id', (req, res) => {
database, etc. const user = Object.assign({}, User, req.body) })// delete a user
app.delete('/users/:id', (req, res) => {
database, etc. })app.listen(3000, () => {
})