일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 31 |
- esbuild
- typescript
- apollo router
- goland
- 티스토리챌린지
- golang
- intellij ide
- elasticsearch
- body size
- AWS
- 오블완
- 사설 ip
- Logrus
- cosine similarity metric
- kube-prometheus-stack
- GoF
- 코사인 유사성 메트릭스
- Kubernetes
- Buffered channel
- 디자인패턴
- javascript
- m4 pro
- go
- http 413
- 배포 프로세스
- 배포 파이프라인
- Infra
- Intellij
- UnBuffered channel
- gitops
- Today
- Total
Fall in IT.
Node.js + OrientDB 사용한 CRUD 본문
안녕하세요. 오늘은 Node.js에서 OrientDB를 연동하고, CRUD하는 방법을 소개하겠습니다.
조금 더 정확히 말하자면, npm(node package manager)에 orientjs를 사용하는 방법을 설명합니다.
Node.js + OrientDB 연동하는 방법
- npm에서 orientjs를 설치합니다.
- $ npm install orientjs --save (https://www.npmjs.com/package/orientjs 참조) - node.js의 설치 및 시작 방법은 아래 링크를 참조하세요.
- http://ithub.tistory.com/31
Node.js + OrientDB CRUD 방법
- CRUD는 기본적으로 Create(insert), Read(select), Update, Delete를 의미합니다.
- npm을 통해 설치한 orientjs 모듈을 불러와서 node.js와 연결해줍니다.
- orientdjs 의 API를 사용하여 node.js에서 데이터베이스의 데이터를 핸들링합니다.
- https://www.npmjs.com/package/orientjs
// select
var sql = 'select * from topic where @rid=:rid';
var param = {
params:{
rid:'#12:0'
}
};
db.query(sql, param).then(function(results){
console.log(results);
});
//insert
var sql = 'insert into topic(title, description) values(:title, :description)';
db.query(sql, {
params:{
title: 'Express',
description: 'Express is framework for web'
}
}).then(function(results){
console.log(results);
});
//delete
var sql = 'delete from topic where title=:title';
db.query(sql, {
params:{
title: 'Express'
}
}).then(function(results){
console.log(results);
});
//update
var sql = 'update topic set title=:title where @rid=:rid';
db.query(sql, {
params:{
title: 'Node.js2',
rid: '#12:1'
}
}).then(function(results){
console.log(results);
})
모두 즐거운 코딩하세요~
'데이터베이스 > OrientDB' 카테고리의 다른 글
OrientDB 설치하기 (0) | 2016.04.09 |
---|