https://github.com/fenos/dqlx
A DGraph Query Builder
https://github.com/fenos/dqlx
builder dgraph
Last synced: about 1 year ago
JSON representation
A DGraph Query Builder
- Host: GitHub
- URL: https://github.com/fenos/dqlx
- Owner: fenos
- Created: 2021-04-22T22:22:30.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2023-01-03T10:16:56.000Z (over 3 years ago)
- Last Synced: 2025-02-27T15:18:48.444Z (about 1 year ago)
- Topics: builder, dgraph
- Language: Go
- Homepage: https://fenos.github.io/dqlx/
- Size: 588 KB
- Stars: 59
- Watchers: 6
- Forks: 15
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# dqlx
dqlx is a fully featured [DGraph](https://github.com/dgraph-io/dgraph) Schema and Query Builder for Go.
It aims to simplify the interaction with the awesome Dgraph database allowing you to fluently compose any queries and mutations of any complexity. It also comes with a rich Schema builder to easily develop and maintain your Dgraph schema.
[](https://circleci.com/gh/fenos/dqlx)
[](https://coveralls.io/github/fenos/dqlx?branch=main)
[](https://goreportcard.com/report/github.com/fenos/dqlx)
---
### Status
The project is getting close to its first official release
### Why?
The DGraph query language is awesome! it is really powerful, and you can achieve a lot with it.
However, as you start trying to add dynamicity (like any other declarative query language) you soon starts
fiddling with a lot strings concatenations and can quickly get messy.
dqlx tries to simplify the interaction with DGraph by helping to construct Queries and mutations with a fluent API.
### Features
- [x] Schema Builder (Types, Predicates, Indexes)
- [x] Filtering - Connecting Filters (AND / OR)
- [x] Nested Selection / Filters
- [x] Functions
- [x] Pagination
- [x] Aggregation
- [x] Sorting
- [x] GroupBy
- [x] Multiple Query Block
- [x] Query Variables
- [x] Values Variables
- [x] Facets
- [x] Mutations
## Documentation
You can find the documentation here: https://fenos.github.io/dqlx
---
### Installation
```bash
go get github.com/fenos/dqlx
```
### Quick Overview
```go
func main() {
// Connect to Dgraph cluster
db, err := dqlx.Connect("localhost:9080")
if err != nil {
log.Fatal()
}
ctx := context.Background()
var animals []map[string]interface{}
// Query for animals
_, err = db.
QueryType("Animal").
Select(`
uid
name
species
age
`).
Filter(
dqlx.Eq{"species": "Cat"},
dqlx.Lt{"age": 5},
).
UnmarshalInto(&animals).
Execute(ctx)
if err != nil { panic(err) }
println(fmt.Sprintf("The animals are: %v", animals))
}
```
### Licence
MIT