티스토리 뷰
1. MongoDB 설치 : https://hoonjo.tistory.com/21
[MongoDB] MongoDB 설치
1. MongoDB? 요약. # MongoDB는 대용량 데이터를 처리하기에 적합한 NoSQL DB이다. 더보기 NoSQL? No SQL, Not Only SQL, Non-Relational Operational Database SQL 등으로 불림. 기존의 관계형 데이터베이스(RDBM..
hoonjo.tistory.com
2. MongoDB Plugin 설치 & MongoDB 연결 (IntelliJ) : https://hoonjo.tistory.com/22
[MongoDB] MongoDB Plugin 설치 (IntelliJ)
1. MongoDB Plugin 설치 (IntelliJ) 2. MongoDB 연결 (MongoDB 실행 명령 : Command > mongod --dbpath C:\MongoDB\db)
hoonjo.tistory.com
(MongoDB 실행 명령 : Command > mongod --dbpath C:\MongoDB\db)
3. MongoDB CRUD : https://hoonjo.tistory.com/23
[MongoDB] CRUD
1. MongoDB 설치 및 실행 이전글 참고 : https://hoonjo.tistory.com/21 [MongoDB] MongoDB 설치 1. MongoDB? 요약. # MongoDB는 대용량 데이터를 처리하기에 적합한 NoSQL DB이다. 더보기 NoSQL? No SQL, Not Onl..
hoonjo.tistory.com
Ref. https://poiemaweb.com/mongdb-basics-shell-crud
4. mongoose module 설치
[MongoDB] Mongoose module 설치
1. nodejs가 설치된 경로로 이동 (1) 경로 확인 (2) 경로 이동 PS C:\Program Files\nodejs> cd 'C:\workspace\Study\Hello NodeJS' PS C:\workspace\Study\Hello NodeJS> dir 디렉터리: C:\workspace\Study\Hell..
hoonjo.tistory.com
5. 연결 테스트
(1) 연결 정보 추가 (index.js)
/* index.js */
var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost:27017/test');
var db = mongoose.connection;
db.on('error', console.error.bind(console, 'connection error:'));
db.once('open', function callback () {
console.log("mongo db connection OK.");
});
(2) Run
정상적으로 연결된 경우 "mongo db connection OK." 이 출력된다.
(3) Sample
/* index.js */
var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost:27017/test');
var db = mongoose.connection;
db.on('error', console.error.bind(console, 'connection error:'));
db.once('open', function callback () {
console.log("mongo db connection OK.");
});
var testSchema = mongoose.Schema({
name: String
});
testSchema.methods.speak = function () {
var greeting = this.name
? "Meow name is " + this.name
: "I don't have a name"
console.log("speak() - " + greeting);
}
var TestModel = mongoose.model("TestModel", testSchema);
var testIns = new TestModel({ name: "testIns"});
testIns.save(function(err, testIns){
if(err) return console.error(err);
testIns.speak();
});
TestModel.find(function(err, models){
if(err) return console.error(err);
console.log("find() - "+models);
});
TestModel.find({name:/^testIns/});
(4) Run
> 결과
"C:\Program Files\JetBrains\IntelliJ IDEA 2017.2.1\bin\runnerw.exe" "C:\Program Files\nodejs\node.exe" "C:\workspace\Study\Hello NodeJS\bin\www"
(node:19736) DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect.
(node:19736) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
mongo db connection OK.
find() -
speak() - Meow name is testIns
6. 데이터 확인
#1. MongoDB 접속
PS C:\Users\line play> mongo
MongoDB shell version v4.2.3
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("생략") }
MongoDB server version: 4.2.3
Server has startup warnings:
2020-02-10T23:56:58.741-0700 I CONTROL [initandlisten]
2020-02-10T23:56:58.741-0700 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2020-02-10T23:56:58.741-0700 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2020-02-10T23:56:58.741-0700 I CONTROL [initandlisten]
2020-02-10T23:56:58.741-0700 I CONTROL [initandlisten] ** WARNING: This server is bound to localhost.
2020-02-10T23:56:58.741-0700 I CONTROL [initandlisten] ** Remote systems will be unable to connect to this server.
2020-02-10T23:56:58.741-0700 I CONTROL [initandlisten] ** Start the server with --bind_ip <address> to specify which IP
2020-02-10T23:56:58.741-0700 I CONTROL [initandlisten] ** addresses it should serve responses from, or with --bind_ip_all to
2020-02-10T23:56:58.742-0700 I CONTROL [initandlisten] ** bind to all interfaces. If this behavior is desired, start the
2020-02-10T23:56:58.742-0700 I CONTROL [initandlisten] ** server with --bind_ip 127.0.0.1 to disable this warning.
2020-02-10T23:56:58.742-0700 I CONTROL [initandlisten]
MongoDB Enterprise >
#2. "test" DB 접속
MongoDB Enterprise > use test
switched to db test
MongoDB Enterprise > db
test
MongoDB Enterprise > show dbs
admin 0.000GB
config 0.000GB
local 0.000GB
test 0.000GB
MongoDB Enterprise >
#3. "testmodels" Collection 확인
MongoDB Enterprise > show collections
testmodels
MongoDB Enterprise > db.test.find()
MongoDB Enterprise > db.testmodels.find()
{ "_id" : ObjectId("5e425379f662ab4d181980dd"), "name" : "testIns", "__v" : 0 }
MongoDB Enterprise >
Ref. https://jdm.kr/blog/21 / https://code-reading.tistory.com/10
TODO. 관심사 추가 - HBASE
'Study > NodeJS' 카테고리의 다른 글
[Node.js] Simple CRUD Project (with MongoDB) (2) | 2020.02.14 |
---|---|
[Node.js] Mongo DB 사용 (2) | 2020.02.11 |
[Node.js] Study. Hello World! (0) | 2020.02.06 |
[Node.js] 팁. Port 설정 (0) | 2020.02.06 |
[Node.js] 환경 설정 및 실행 (1) | 2020.02.06 |
- Total
- Today
- Yesterday
- phaser
- 지갑 생성
- mongodb
- 채굴
- pharser
- go lang
- nodejs
- minting
- 뱀파이어 서바이벌
- 이더리움 채굴기
- Vampire Survivor
- 비트코인
- krafterspace
- phaser3
- Linux
- 네이버 클라우드 플랫폼
- 뱀파이어 사바이벌
- GO
- 이더리움
- remote-ftp
- mysql
- node
- pharser3
- node.js
- 모니터 설정
- 민팅
- OpenSea
- 몽고db
- 회원 탈퇴
- P3X Redis UI
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |