Files
ent/entc/integration/customid/ent/blob.go
2019-12-24 10:29:40 +02:00

91 lines
2.5 KiB
Go

// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
// This source code is licensed under the Apache 2.0 license found
// in the LICENSE file in the root directory of this source tree.
// Code generated by entc, DO NOT EDIT.
package ent
import (
"fmt"
"strings"
"github.com/facebookincubator/ent/entc/integration/customid/ent/blob"
"github.com/google/uuid"
)
// Blob is the model entity for the Blob schema.
type Blob struct {
config `json:"-"`
// ID of the ent.
ID uuid.UUID `json:"id,omitempty"`
// UUID holds the value of the "uuid" field.
UUID uuid.UUID `json:"uuid,omitempty"`
}
// scanValues returns the types for scanning values from sql.Rows.
func (*Blob) scanValues() []interface{} {
return []interface{}{
&uuid.UUID{},
&uuid.UUID{},
}
}
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the Blob fields.
func (b *Blob) assignValues(values ...interface{}) error {
if m, n := len(values), len(blob.Columns); m != n {
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
}
if value, ok := values[0].(*uuid.UUID); !ok {
return fmt.Errorf("unexpected type %T for field id", values[0])
} else if value != nil {
b.ID = *value
}
values = values[1:]
if value, ok := values[0].(*uuid.UUID); !ok {
return fmt.Errorf("unexpected type %T for field uuid", values[0])
} else if value != nil {
b.UUID = *value
}
return nil
}
// Update returns a builder for updating this Blob.
// Note that, you need to call Blob.Unwrap() before calling this method, if this Blob
// was returned from a transaction, and the transaction was committed or rolled back.
func (b *Blob) Update() *BlobUpdateOne {
return (&BlobClient{b.config}).UpdateOne(b)
}
// Unwrap unwraps the entity that was returned from a transaction after it was closed,
// so that all next queries will be executed through the driver which created the transaction.
func (b *Blob) Unwrap() *Blob {
tx, ok := b.config.driver.(*txDriver)
if !ok {
panic("ent: Blob is not a transactional entity")
}
b.config.driver = tx.drv
return b
}
// String implements the fmt.Stringer.
func (b *Blob) String() string {
var builder strings.Builder
builder.WriteString("Blob(")
builder.WriteString(fmt.Sprintf("id=%v", b.ID))
builder.WriteString(", uuid=")
builder.WriteString(fmt.Sprintf("%v", b.UUID))
builder.WriteByte(')')
return builder.String()
}
// Blobs is a parsable slice of Blob.
type Blobs []*Blob
func (b Blobs) config(cfg config) {
for _i := range b {
b[_i].config = cfg
}
}