Как я могу произвести мутацию в Dgraph из структуры? - PullRequest
2 голосов
/ 04 августа 2020

Я пытаюсь реализовать Dgraph в Go. Есть ли способ отправить каждую структуру в базу данных? Моя структура выглядит так:

type Comprador struct {
    Id   string  `json:"id,omitempty"`
    Name string  `json:"name,omitempty"`
    Age  float64 `json:"age,omitempty"`
}

type Producto struct {
    Id    string
    Name  string
    Price float64
}

type Transaccion struct {
    Id          string
    BuyerId     Comprador
    IP          string
    Device      string
    ProductsIds []Producto
}

И моя схема в Dgraph выглядит так:

type Compradores {
    id: ID!
    fecha: DateTime
    name: String
    age: Int
}

type Productos{
    id: ID!
    fecha: DateTime
    name: String
    price: Int
}

type Transacciones{ 
    id: ID!
    fecha: DateTime
    buyerId: Compradores
    ip: String
    device: String
    products: [Productos]
}

Поскольку моя структура и моя схема имеют одинаковые атрибуты, я просто хочу изменить каждый структура в Dgraph.

...