Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kevinmichaelchen/surreal-demo
https://github.com/kevinmichaelchen/surreal-demo
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/kevinmichaelchen/surreal-demo
- Owner: kevinmichaelchen
- Created: 2023-12-26T19:49:32.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2023-12-27T00:32:34.000Z (12 months ago)
- Last Synced: 2024-06-20T22:27:54.462Z (6 months ago)
- Language: Go
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Taking [SurrealDB][surreal] for a spin. The domain I'm interested in exploring is wide, high-branching-factor trees, like the _organizational unit_ structures you'd find in [LDAP][ldap] systems. Imagine a forest of millions of trees, where each tree can have an arbitrary height (going up to, say, 10) and potentially thousands of children (“subordinate OUs”).
[surreal]: https://surrealdb.com/
[ldap]: https://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol## Starting
[run-docker]: https://docs.surrealdb.com/docs/installation/running/docker
Spin up the database [with Docker][run-docker]:
```shell
docker run --rm --pull always -p 8000:8000 surrealdb/surrealdb:latest start
```Create some data with:
```shell
go run main.go
```## GUI
Surrealist has the most GitHub stars — by a long shot — so visit
https://surrealist.app and start a new session.## Query
```
-- Select ancestors and descendants of Org Unit 123
SELECT
/* parent */
<-belongs_to<-org_unit,/* grandparent */
<-belongs_to<-org_unit<-belongs_to<-org_unit,/* children */
->belongs_to->org_unit,/* grandchildren */
->belongs_to->org_unit->belongs_to->org_unit
FROM org_unit:123;
```returns
```json
[
{
"children": [
"org_unit:cm5m9km1fpl4pmfrtn3g"
],
"grandchildren": [],
"grandparent": [],
"parent": [
"org_unit:cm5m9km1fpl4pmfrtn50",
"org_unit:cm5m9km1fpl4pmfrtn4g"
]
}
]
```## Experimenting
### Exporting Data
Use the [`export`][export] command to create a new dataset.
[export]: https://docs.surrealdb.com/docs/cli/export/
```shell
pkgx surreal export --namespace default --database default
```### Importing Dataset
Use the [`import`][import] command to import a dataset.
[import]: https://docs.surrealdb.com/docs/cli/import/
```shell
pkgx surreal import --namespace default --database default
```