How I can make a mutation in Dgraph from a struct?

103 Views Asked by At

I'm trying to implement a Dgraph in Go. There's any way to send each struct to the database? My struct looks like this:

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
}

And my Schema in the Dgraph looks like this:

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]
}

As my struct and my schema have the same attributes I just want to mutate each struct in the Dgraph.

0

There are 0 best solutions below