-
mongo DB 사용해보기카테고리 없음 2022. 12. 8. 15:51
1. 설치 후 shell 에서 테스트 해보기
몽고DB on-premiss 설치
https://www.mongodb.com/try/download/enterprise
몽고DB Shell 설치
https://www.mongodb.com/try/download/shell
localhost:27017
show dbs
use local
db.collection.insertOne({test: 'newValue'})
db.collection.find()
db.collection.insertMany([
{resource: 'moniter', maker: 'benq', host: 'micube'},
{resource: 'laptop', maker: 'asus', host: 'micube'}
])
db.collection.find()
db.collection.find({host: 'micube'})2. node.js express 에서 connection 테스트 해보기
npm install mongoose
slackbotexpress/routes/index.js 에 추가
const mongoose = require("mongoose");mongoose.set('strictQuery', true);
mongoose.connect('mongodb://127.0.0.1:27017').then((response) => {console.log('Successfully connected to mongodb');}).catch(e => {console.error(e);});