35 lines
702 B
Go
35 lines
702 B
Go
// Copyright 2019-present Facebook Inc. 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.
|
|
|
|
package schema
|
|
|
|
import (
|
|
"entgo.io/ent"
|
|
"entgo.io/ent/schema/edge"
|
|
"entgo.io/ent/schema/field"
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
// Car holds the schema definition for the Car entity.
|
|
type Car struct {
|
|
ent.Schema
|
|
}
|
|
|
|
// Fields of the Car.
|
|
func (Car) Fields() []ent.Field {
|
|
return []ent.Field{
|
|
field.UUID("id", uuid.UUID{}).
|
|
Default(uuid.New),
|
|
field.String("number").
|
|
Optional(),
|
|
}
|
|
}
|
|
|
|
// Edges of the Car.
|
|
func (Car) Edges() []ent.Edge {
|
|
return []ent.Edge{
|
|
edge.To("rentals", Rental.Type),
|
|
}
|
|
}
|