While each Modus SDK offers similar capabilities, the APIs and usage may vary between languages.

Modus Dgraph APIs documentation is available on the following pages:

The Modus Dgraph APIs allow you to run queries and mutations against a Dgraph database.

Import

To begin, import the dgraph package from the SDK:

import "github.com/hypermodeinc/modus/sdk/go/pkg/dgraph"

Dgraph APIs

The APIs in the dgraph package are below, organized by category.

We’re constantly introducing new APIs through ongoing development with early users. Please open an issue if you have ideas on what would make Modus even more powerful for your next app!

Functions

AlterSchema

Alter the schema of a Dgraph database.

func AlterSchema(connection, schema string) error
connection
string
required

Name of the connection, as defined in the manifest.

schema
string
required

The schema to apply to the Dgraph database.

DropAll

Drop all data from a Dgraph database.

func DropAll(connection string) error
connection
string
required

Name of the connection, as defined in the manifest.

DropAttr

Drop an attribute from a Dgraph schema.

func DropAttr(connection, attr string) error
connection
string
required

Name of the connection, as defined in the manifest.

attr
string
required

The attribute to drop from the Dgraph schema.

Execute

Execute a Dgraph query or mutation using a Dgraph Request object.

func Execute(connection string, request *Request) (*Response, error)
connection
string
required

Name of the connection, as defined in the manifest.

request
*Request
required

A pointer to a Dgraph Request object, describing the query or mutation to execute.

Types

Mutation

A Dgraph mutation object, used to execute mutations.

type Mutation struct {
  SetJson   string
  DelJson   string
  SetNquads string
  DelNquads string
  Condition string
}
SetJson
string

A JSON string representing the data to set in the mutation.

DelJson
string

A JSON string representing the data to delete in the mutation.

SetNquads
string

A string representing the data to set in the mutation in NQuads format.

DelNquads
string

A string representing the data to delete in the mutation in NQuads format.

Condition
string

A string representing the condition query for the mutation.

Query

A Dgraph query object, used to execute queries.

type Query struct {
  Query     string
  Variables map[string]string
}
Query
string

The DQL query to execute.

Variables
map[string]string

A map of query variables.

Request

A Dgraph request object, used to execute queries and mutations.

type Request struct {
  Query     *Query
  Mutations []*Mutation
}
Query
*Query

A pointer to a Dgraph query object.

Mutations
[]*Mutation

An slice of pointers to Dgraph mutation objects.