Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eatonphil/docdb
Basic document db from scratch in Go
https://github.com/eatonphil/docdb
Last synced: 23 days ago
JSON representation
Basic document db from scratch in Go
- Host: GitHub
- URL: https://github.com/eatonphil/docdb
- Owner: eatonphil
- License: mit
- Created: 2022-03-28T15:51:09.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-04-02T21:28:30.000Z (over 2 years ago)
- Last Synced: 2024-10-13T04:13:05.468Z (about 1 month ago)
- Language: Go
- Size: 40 KB
- Stars: 46
- Watchers: 3
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# docdb
A simple Go document database.
## Build
Grab Go 1.18 and this repo. Inside this repo run:
```bash
$ go build
$ ./docdb
```## Usage
Then in another terminal:
```bash
$ curl -X POST -H 'Content-Type: application/json' -d '{"name": "Kevin", "age": "45"}' http://localhost:8080/docs
{"body":{"id":"5ac64e74-58f9-4ba4-909e-1d5bf4ddcaa1"},"status":"ok"}
$ curl --get http://localhost:8080/docs --data-urlencode 'q=name:"Kevin"' | jq
{
"body": {
"count": 1,
"documents": [
{
"body": {
"age": "45",
"name": "Kevin"
},
"id": "5ac64e74-58f9-4ba4-909e-1d5bf4ddcaa1"
}
]
},
"status": "ok"
}
$ curl --get http://localhost:8080/docs --data-urlencode 'q=age:<50' | jq
{
"body": {
"count": 1,
"documents": [
{
"body": {
"age": "45",
"name": "Kevin"
},
"id": "5ac64e74-58f9-4ba4-909e-1d5bf4ddcaa1"
}
]
},
"status": "ok"
}
```