next
를 누르면 되고, Choose Setup Type
이 나오면 Complete
를 선택해준다.Install MongoD as a Service
를 선택하게 되면 클라우드가 내 데이터베이스 서버가 되는데, 선택 해제
후 Next
해준다.Install MongoDB Compass
를 체크하고 설치를 진행하면 MySQL 워크벤치와 비슷한 역할을 하는 Compass까지 함께 설치된다. 필요하다면 선택
해주고 Next
후 MongoDB를 설치한다.C:\Program Files\MongoDB\Server\6.0\bin
에 설치되었기 때문에 설치된 경로의 bin파일로 이동한 뒤 몽고디비 서버인 mongod.exe
를 실행시켜 서버를 연다.http://localhost:27017
에 접속했을 때 It looks like you are trying to access MongoDB over HTTP on the native driver port.
라는 문구가 뜨면 MongoDB 서버에 잘 연결된 것이다.C:\Program Files\MongoDB\Server\6.0\bin
에 설치되었기 때문에 설치된 경로의 bin파일로 직접 이동해서 MongoDB 명령어를 수행하거나, 환경 변수에 MongoDB 설치경로\bin을 등록(참고 : https://smecsm.tistory.com/198)하고 해당 디렉토리로 이동하지 않아도 명령어를 쓸 수 있게 해준다. 새로운 명령프롬프트
를 열어 C드라이브로 이동 후 mongod
명령어를 입력하면 몽고디비를 사용할 수 있다.use 데이터베이스명
: 데이터베이스를 생성해준다. 해당 데이터베이스가 이미 있다면 데이터베이스를 실행한다.show dbs
: 현재 생성되어있는 데이터베이스 목록을 출력한다.db
: 현재 실행중인 데이터베이스를 출력한다.db.stats()
: 현재 실행중인 데이터베이스의 상세정보가 출력된다.db.dropDatabase()
: 현재 실행중인 데이터베이스를 삭제한다.db.createCollection("컬렉션명")
: Collection을 생성한다.show collections
: Collection을 조회한다.db.컬렉션명.drop()
: 해당 컬렉션명의 Collection을 삭제한다.db.컬렉션명.insert({"key" : "값", "key2" : "값"})
: 컬렉션에 데이터를 생성한다. 이처럼 서로 다른 값을 추가로 넣어도 입력이 가능하다.db.컬렉션명.find()
: 컬렉션의 값을 조회한다. 결과로는 Cursor를 반환하는데, 커서는 쿼리 요청의 결과 값을 가르키는 포인터이다. 커서 객체를 통해 보이는 데이터의 수를 제한하거나 정렬할 수도 있다.db.컬렉션명.remove({"key":"value"})
: 해당 키와 값이 있는 Document를 삭제한다.ㅇㅅㅇ
: 그 외 명령어는 여기에 정리되어 있으니 필요할 때 찾아보면 된다.mongoose 설치
npm install mongoose
mongoose 불러오기
const mongoose = require("mongoose");
db연결 코드 작성
// 데이터베이스 연결(27017 : MongoDB 기본 포트)
mongoose.connect("mongodb://127.0.0.1:27017/facebook", {
useNewUrlParser : true,
useCreateIndex : true,
}).then(()=>{
console.log("MongoDB에 연결되었습니다 ㅇㅅㅇ");
}).catch((err)=>{
console.error(err);
});
// newCustomer 스키마 정의(앞에서 이미 customer 컬렉션을 생성했으므로)
const customerSchema = mongoose.Schema({
name : "string",
age : "number",
gender : "string"
}, {
collection : "newCustomer"
});
// 스키마를 모델로 변환
const Customer = mongoose.model("Schema", customerSchema);
// 모델로 인스턴스 생성
const customer1 = new Customer({ name : "홍길동", age : "23", gender : "남성"});
// 생성한 인스턴스(Document)를 DB에 저장
customer1.save().then(()=>{
console.log(customer1);
}).catch((err)=>{
console.error(err);
});
node 해당파일명
https://bothbest.amebaownd.com/
https://bambooflooring.shopinfo.jp/
https://bamboochopsticks.storeinfo.jp/
https://bothbest.seesaa.net/
https://bothbest.mystrikingly.com
https://zybuluo.com/bothbest/note/2624938
https://bothbest.amebaownd.com/posts/57445395
https://bamboochopsticks.storeinfo.jp/posts/57445422
https://bambooflooring.shopinfo.jp/posts/57445427
https://bothbest.seesaa.net/article/518162762.html
https://bambooflooring.notion.site/bothbest-26f41b6b363980b0865fd008cf78ea7a
https://connect.usama.dev/blogs/37095/How-to-Choose-Bamboo-Decking-That-Lasts-15-Years
https://bothbest.mystrikingly.com/blog/choosing-bamboo-flooring-that-withstands-kids-and-pets
https://bambooflooring.notion.site/From-Forest-to-Floor-A-Step-by-Step-Guide-to-Bamboo-Flooring-Manufacturing-27141b6b363980f6bc45ea303bea1f0d