Implementation of nestedset model on RDBMS using go. It offers REST APIs to operate on nested set data. please read in the following links to know more about what is nestedset and why we needed in RDBMS.
Nestedset Implementation in RDBMS
Install sqlite3, as the application uses sqlite3 as a default backend.
apt install sqlite3
The program has its own library dependencies to interact with different modules. We use 'dep' package manager to manage the library dependacy. Install the 'dep' with following command,
apt install go-dep
Under the source tree(not under the application root folder), please run the following command once to download all the relevant dependanices. You may get compilation errors, if all the libraries are not present in the system.
dep ensure
compile the application as below in the top directory.
make
After the compilation, simply run the following command to start the application
./bin/NestedSet
- Request(GET)
http://localhost:8080/data
- Response
[
{
"uid": "00112233-4455-6677-8899-aabbccddeeff",
"puid": "",
"name": "root",
"desc": "The default root node in the hierarchy",
"lftId": 1,
"rgtId": 6
},
{
"uid": "bc5ca89d-696a-45f1-914d-e9d7d78b2067",
"puid": "00112233-4455-6677-8899-aabbccddeeff",
"name": "B",
"desc": "Sugesh is the record",
"lftId": 2,
"rgtId": 5
},
{
"uid": "8fad71a0-bae3-49fb-a587-37abfd414554",
"puid": "bc5ca89d-696a-45f1-914d-e9d7d78b2067",
"name": "B",
"desc": "Sugesh is the record",
"lftId": 3,
"rgtId": 4
}
]
- Request (GET)
http://localhost:8080/data/id/bc5ca89d-696a-45f1-914d-e9d7d78b2067
- Response
{
"uid": "bc5ca89d-696a-45f1-914d-e9d7d78b2067",
"puid": "00112233-4455-6677-8899-aabbccddeeff",
"name": "B",
"desc": "Sugesh is the record",
"lftId": 2,
"rgtId": 5
}
- Request(GET)
http://localhost:8080/data/name/B
- Response
[
{
"uid": "bc5ca89d-696a-45f1-914d-e9d7d78b2067",
"puid": "00112233-4455-6677-8899-aabbccddeeff",
"name": "B",
"desc": "Sugesh is the record",
"lftId": 2,
"rgtId": 5
},
{
"uid": "8fad71a0-bae3-49fb-a587-37abfd414554",
"puid": "bc5ca89d-696a-45f1-914d-e9d7d78b2067",
"name": "B",
"desc": "Sugesh is the record",
"lftId": 3,
"rgtId": 4
}
]
- Request(POST)
http://localhost:8080/data
{ "name":"M",
"desc":"Sugesh is the record",
"puid":"bc5ca89d-696a-45f1-914d-e9d7d78b2067"
}
- Response
201 Created
{Error code otherwise}
- Request(DELETE)
http://localhost:8080/data/id/ee0dce03-3be5-47ed-9807-d291ed3cfbb7
- Response
200 STATUS OK
{ Error code incase operation failed}