@somkiat.cc
1
Git ๤ําหรับเก็บ code
2
Git ๤ําหรับเก็บ data ?
3
4
NoSQL
No SQL
Not only SQL
Non-relational database
Schema-less
6
7
Git ?
8
Git as a data store ?
9
Create database
$git init hello && cd hello
Initialized empty Git repository in ./hello/.git/
10
Create data
$echo '{"id": 1, "name": "Somkiat", "age": 30}' > 1.json
$git add 1.json
$git commit -m "Create new person"
[master (root-commit) c1809c0] Create new person
1 file changed, 1 insertion(+)
create mode 100644 1.json
11
Read data
$git show master:1.json
{"id": 1, "name": "Somkiat", "age": 30}
12
Create with hash object
$echo '{"id": 1, "name": "Somkiat", "age": 30}' | 
git hash-object -w --stdin
f8d407f8880d3126c45cc38dee9f025ddcd816ad
13
Read data
$git cat-file -p f8d407
{"id": 1, "name": "Somkiat", "age": 30}
14
Key-value database !!
15
Git data model
16
.git/objects
reference
master
commit
c1809
tree
bb819
blob
d092a
tree
ab123
blob
67ab9
17
Let’s programming
18
Git store
$git store set key value
$git store get key
$git store keys
$git store save
$git store clear
19
Git workflow
20
Speed
On my machine 100 commits/second
21
Transaction
22
Concurrency
23
Backup
24
Replication
25
Git as NoSQL
Key-value
@somkiat.cc
26
27
Resources
https://github.com/up1/demo-git-as-nosql

Git as NoSQL