콘텐츠로 이동

빠른 시작

Actionbase Quick Start Demo
  • Docker
Terminal window
docker run -it ghcr.io/kakao/actionbase:standalone

이 명령은 서버를 백그라운드(port 8080)에서 실행하고, CLI는 포그라운드에서 실행합니다.

actionbase>

미리 준비된 샘플 데이터를 다음 프롬프트(actionbase>)에서 불러옵니다:

load preset likes

이 명령은 likes 데이터베이스/테이블을 생성하고 3개의 엣지를 삽입합니다:

│ 3 edges inserted
│ - Alice → Phone
│ - Bob → Phone
│ - Bob → Laptop
Alice --- likes ----> +--------+
| Phone |
Bob ----- likes ----> +--------+
|
| +--------+
+-- likes ----> | Laptop |
+--------+

쓰기 시점에 Actionbase는 모든 것을 미리 계산합니다. 읽기용 카운트, 인덱스, 정렬 정보를 양방향 모두 미리 준비해두므로, 즉시 다음 쿼리를 실행할 수 있습니다.

“Bob이 좋아한 것은?” (direction: OUT)

“Phone을 좋아한 사람은?” (방향: IN)

카운트와 인덱스가 쓰기 시점에 이미 준비되어 있으므로, 쿼리 시점에는 추가 계산이 필요 없습니다.

REST API 예시

curl을 사용하려면 -p 8080:8080 옵션으로 실행하고, 다른 터미널에서 다음 명령을 실행하세요:

Terminal window
docker run -it -p 8080:8080 ghcr.io/kakao/actionbase:standalone

서비스(데이터베이스) 생성

Terminal window
curl -X POST "http://localhost:8080/graph/v2/service/likes" \
-H "Content-Type: application/json" \
-d '{"desc":"Likes"}'

레이블(테이블) 생성

Terminal window
curl -X POST "http://localhost:8080/graph/v2/service/likes/label/likes" \
-H "Content-Type: application/json" \
-d '{
"desc":"Like",
"type":"INDEXED",
"schema":{
"src":{"type":"STRING"},
"tgt":{"type":"STRING"},
"fields":[{"name":"created_at","type":"LONG","nullable":false}]
},
"dirType":"BOTH",
"storage":"datastore://likes/likes",
"indices":[{"name":"recent","fields":[{"name":"created_at","order":"DESC"}]}]
}'

엣지 삽입

Terminal window
curl -X POST "http://localhost:8080/graph/v3/databases/likes/tables/likes/edges" \
-H "Content-Type: application/json" \
-d '{
"mutations":[
{"type":"INSERT","edge":{"version":1737377177245,"source":"Alice","target":"Phone","properties":{"created_at":1737377177245}}},
{"type":"INSERT","edge":{"version":1737377177297,"source":"Bob","target":"Phone","properties":{"created_at":1737377177297}}},
{"type":"INSERT","edge":{"version":1737377177350,"source":"Bob","target":"Laptop","properties":{"created_at":1737377177350}}}
]
}'

특정 엣지가 존재하는지 확인:

get --source Alice --target Phone
│ The edge is found: [Alice -> Phone]
│ |---------------|--------|--------|---------------------------|
│ | VERSION | SOURCE | TARGET | PROPERTIES |
│ |---------------|--------|--------|---------------------------|
│ | 1737377177245 | Alice | Phone | created_at: 1737377177245 |
│ |---------------|--------|--------|---------------------------|
REST API 대응
Terminal window
curl "http://localhost:8080/graph/v3/databases/likes/tables/likes/edges/get?source=Alice&target=Phone"

What did Bob like? (direction: OUT)

scan --index recent --start Bob --direction OUT
│ The 2 edges found (offset: -, hasNext: false)
│ |---|---------------|--------|--------|---------------------------|
│ | # | VERSION | SOURCE | TARGET | PROPERTIES |
│ |---|---------------|--------|--------|---------------------------|
│ | 1 | 1737377177350 | Bob | Laptop | created_at: 1737377177350 |
│ | 2 | 1737377177297 | Bob | Phone | created_at: 1737377177297 |
│ |---|---------------|--------|--------|---------------------------|

Who liked Phone? (direction: IN)

scan --index recent --start Phone --direction IN
│ The 2 edges found (offset: -, hasNext: false)
│ |---|---------------|--------|--------|---------------------------|
│ | # | VERSION | SOURCE | TARGET | PROPERTIES |
│ |---|---------------|--------|--------|---------------------------|
│ | 1 | 1737377177297 | Bob | Phone | created_at: 1737377177297 |
│ | 2 | 1737377177245 | Alice | Phone | created_at: 1737377177245 |
│ |---|---------------|--------|--------|---------------------------|
REST API 대응
Terminal window
# OUT {#out}
curl "http://localhost:8080/graph/v3/databases/likes/tables/likes/edges/scan/recent?start=Bob&direction=OUT"
# IN {#in}
curl "http://localhost:8080/graph/v3/databases/likes/tables/likes/edges/scan/recent?start=Phone&direction=IN"

How many items did Alice like? (direction: OUT)

count --start Alice --direction OUT
│ |-------|-----------|-------|
│ | START | DIRECTION | COUNT |
│ |-------|-----------|-------|
│ | Alice | OUT | 1 |
│ |-------|-----------|-------|

How many users liked Phone? (direction: IN)

count --start Phone --direction IN
│ |-------|-----------|-------|
│ | START | DIRECTION | COUNT |
│ |-------|-----------|-------|
│ | Phone | IN | 2 |
│ |-------|-----------|-------|
REST API 대응
Terminal window
# OUT {#out}
curl "http://localhost:8080/graph/v3/databases/likes/tables/likes/edges/count?start=Alice&direction=OUT"
# IN {#in}
curl "http://localhost:8080/graph/v3/databases/likes/tables/likes/edges/count?start=Phone&direction=IN"

(이 문서는 Kanana-2로 번역되었습니다. 번역 기여를 환영합니다!)