3 글 보임 - 1 에서 3 까지 (총 3 중에서)
-
글쓴이글
-
2024년 8월 6일 18:10 #129184
박정범호참가자const express = require('express') const app = express()
const { MongoClient } = require('mongodb')
let db const url = 'mongodb+srv://@cluster0.xnv6jzp.mongodb.net/?retryWrites=true&w=majority&appName=Cluster0'
new MongoClient(url).connect().then((client)=>{ console.log('DB연결성공') db = client.db('forum') }).catch((err)=>{ console.log(err) })
app.listen(8080, () => { console.log('http://localhost:8080 에서 서버 실행중') })
app.get('/', (요청, 응답) => { 응답.send('반갑다') })
app.get('/news', (요청, 응답) => { db.collection('post').insertOne({title :'어쩌구'}) // 응답.send('오늘 비옴 ') }) /news 을 입력해서 mongodb에 연결됐는지 확인하려고 하면 페이지 에러가 끕니다 그리고 에러창에는 [nodemon] app crashed - waiting for file changes before starting이게 뜹니다 ㅜㅜ
-
이 게시글은
codingapple에 의해 11 월, 1 주 전에 수정됐습니다.
2024년 8월 6일 18:16 #129185
박정범호참가자오류는 이렇게 뜹니다 ! 그리고 저 아이디랑 패스워드 입력할때도 저장하면 db연결이 나와야되는데 저장하면 나오지않고 nodemon server.js 해야지 나옵니다 잘못된것일까요 http://localhost:8080 에서 서버 실행중 DB연결성공 C:\Users\pjh05\Desktop\forum\node_modules\mongodb\lib\cmap\connection.js:202 callback(new error_1.MongoServerError(document)); ^
MongoServerError: user is not allowed to do action [insert] on [forum.post] at Connection.onMessage (C:\Users\pjh05\Desktop\forum\node_modules\mongodb\lib\cmap\connection.js:202:26) at MessageStream.<anonymous> (C:\Users\pjh05\Desktop\forum\node_modules\mongodb\lib\cmap\connection.js:61:60) at MessageStream.emit (node:events:519:28) at processIncomingData (C:\Users\pjh05\Desktop\forum\node_modules\mongodb\lib\cmap\message_stream.js:124:16) at MessageStream._write (C:\Users\pjh05\Desktop\forum\node_modules\mongodb\lib\cmap\message_stream.js:33:9) at writeOrBuffer (node:internal/streams/writable:570:12) at _write (node:internal/streams/writable:499:10) at Writable.write (node:internal/streams/writable:508:10) at TLSSocket.ondata (node:internal/streams/readable:1007:22) at TLSSocket.emit (node:events:519:28) { ok: 0, code: 8000, codeName: 'AtlasError', [Symbol(errorLabels)]: Set(0) {} }
Node.js v20.16.0 [nodemon] app crashed - waiting for file changes before starting...
-
이 게시글은
-
글쓴이글
3 글 보임 - 1 에서 3 까지 (총 3 중에서)
- 답변은 로그인 후 가능합니다.