2

我正在尝试在 Go 中实现 Dgraph。有什么方法可以将每个结构发送到数据库?我的结构如下所示:

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 中的 Schema 如下所示:

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 中的每个结构。

4

0 回答 0