ent/doc: O2M same type example

Reviewed By: alexsn

Differential Revision: D17050185

fbshipit-source-id: ef12cc82ab9bf155713faf94129fd5fe503664e4
This commit is contained in:
Ariel Mashraki
2019-08-26 03:17:15 -07:00
committed by Facebook Github Bot
parent 551236f06d
commit 3e018277b1
23 changed files with 2476 additions and 3 deletions

View File

@@ -0,0 +1,29 @@
// Code generated (@generated) by entc, DO NOT EDIT.
package node
const (
// Label holds the string label denoting the node type in the database.
Label = "node"
// FieldID holds the string denoting the id field in the database.
FieldID = "id"
// FieldValue holds the string denoting the value vertex property in the database.
FieldValue = "value"
// Table holds the table name of the node in the database.
Table = "nodes"
// ParentTable is the table the holds the parent relation/edge.
ParentTable = "nodes"
// ParentColumn is the table column denoting the parent relation/edge.
ParentColumn = "parent_id"
// ChildrenTable is the table the holds the children relation/edge.
ChildrenTable = "nodes"
// ChildrenColumn is the table column denoting the children relation/edge.
ChildrenColumn = "parent_id"
)
// Columns holds all SQL columns are node fields.
var Columns = []string{
FieldID,
FieldValue,
}

View File

@@ -0,0 +1,300 @@
// Code generated (@generated) by entc, DO NOT EDIT.
package node
import (
"github.com/facebookincubator/ent/examples/o2mrecur/ent/predicate"
"github.com/facebookincubator/ent/dialect/sql"
)
// ID filters vertices based on their identifier.
func ID(id int) predicate.Node {
return predicate.Node(
func(s *sql.Selector) {
s.Where(sql.EQ(s.C(FieldID), id))
},
)
}
// IDEQ applies the EQ predicate on the ID field.
func IDEQ(id int) predicate.Node {
return predicate.Node(
func(s *sql.Selector) {
s.Where(sql.EQ(s.C(FieldID), id))
},
)
}
// IDNEQ applies the NEQ predicate on the ID field.
func IDNEQ(id int) predicate.Node {
return predicate.Node(
func(s *sql.Selector) {
s.Where(sql.NEQ(s.C(FieldID), id))
},
)
}
// IDGT applies the GT predicate on the ID field.
func IDGT(id int) predicate.Node {
return predicate.Node(
func(s *sql.Selector) {
s.Where(sql.GT(s.C(FieldID), id))
},
)
}
// IDGTE applies the GTE predicate on the ID field.
func IDGTE(id int) predicate.Node {
return predicate.Node(
func(s *sql.Selector) {
s.Where(sql.GTE(s.C(FieldID), id))
},
)
}
// IDLT applies the LT predicate on the ID field.
func IDLT(id int) predicate.Node {
return predicate.Node(
func(s *sql.Selector) {
s.Where(sql.LT(s.C(FieldID), id))
},
)
}
// IDLTE applies the LTE predicate on the ID field.
func IDLTE(id int) predicate.Node {
return predicate.Node(
func(s *sql.Selector) {
s.Where(sql.LTE(s.C(FieldID), id))
},
)
}
// IDIn applies the In predicate on the ID field.
func IDIn(ids ...int) predicate.Node {
return predicate.Node(
func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(ids) == 0 {
s.Where(sql.False())
return
}
v := make([]interface{}, len(ids))
for i := range v {
v[i] = ids[i]
}
s.Where(sql.In(s.C(FieldID), v...))
},
)
}
// IDNotIn applies the NotIn predicate on the ID field.
func IDNotIn(ids ...int) predicate.Node {
return predicate.Node(
func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(ids) == 0 {
s.Where(sql.False())
return
}
v := make([]interface{}, len(ids))
for i := range v {
v[i] = ids[i]
}
s.Where(sql.NotIn(s.C(FieldID), v...))
},
)
}
// Value applies equality check predicate on the "value" field. It's identical to ValueEQ.
func Value(v int) predicate.Node {
return predicate.Node(
func(s *sql.Selector) {
s.Where(sql.EQ(s.C(FieldValue), v))
},
)
}
// ValueEQ applies the EQ predicate on the "value" field.
func ValueEQ(v int) predicate.Node {
return predicate.Node(
func(s *sql.Selector) {
s.Where(sql.EQ(s.C(FieldValue), v))
},
)
}
// ValueNEQ applies the NEQ predicate on the "value" field.
func ValueNEQ(v int) predicate.Node {
return predicate.Node(
func(s *sql.Selector) {
s.Where(sql.NEQ(s.C(FieldValue), v))
},
)
}
// ValueGT applies the GT predicate on the "value" field.
func ValueGT(v int) predicate.Node {
return predicate.Node(
func(s *sql.Selector) {
s.Where(sql.GT(s.C(FieldValue), v))
},
)
}
// ValueGTE applies the GTE predicate on the "value" field.
func ValueGTE(v int) predicate.Node {
return predicate.Node(
func(s *sql.Selector) {
s.Where(sql.GTE(s.C(FieldValue), v))
},
)
}
// ValueLT applies the LT predicate on the "value" field.
func ValueLT(v int) predicate.Node {
return predicate.Node(
func(s *sql.Selector) {
s.Where(sql.LT(s.C(FieldValue), v))
},
)
}
// ValueLTE applies the LTE predicate on the "value" field.
func ValueLTE(v int) predicate.Node {
return predicate.Node(
func(s *sql.Selector) {
s.Where(sql.LTE(s.C(FieldValue), v))
},
)
}
// ValueIn applies the In predicate on the "value" field.
func ValueIn(vs ...int) predicate.Node {
v := make([]interface{}, len(vs))
for i := range v {
v[i] = vs[i]
}
return predicate.Node(
func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(vs) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldValue), v...))
},
)
}
// ValueNotIn applies the NotIn predicate on the "value" field.
func ValueNotIn(vs ...int) predicate.Node {
v := make([]interface{}, len(vs))
for i := range v {
v[i] = vs[i]
}
return predicate.Node(
func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(vs) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldValue), v...))
},
)
}
// HasParent applies the HasEdge predicate on the "parent" edge.
func HasParent() predicate.Node {
return predicate.Node(
func(s *sql.Selector) {
t1 := s.Table()
s.Where(sql.NotNull(t1.C(ParentColumn)))
},
)
}
// HasParentWith applies the HasEdge predicate on the "parent" edge with a given conditions (other predicates).
func HasParentWith(preds ...predicate.Node) predicate.Node {
return predicate.Node(
func(s *sql.Selector) {
t1 := s.Table()
t2 := sql.Select(FieldID).From(sql.Table(ParentTable))
for _, p := range preds {
p(t2)
}
s.Where(sql.In(t1.C(ParentColumn), t2))
},
)
}
// HasChildren applies the HasEdge predicate on the "children" edge.
func HasChildren() predicate.Node {
return predicate.Node(
func(s *sql.Selector) {
t1 := s.Table()
s.Where(
sql.In(
t1.C(FieldID),
sql.Select(ChildrenColumn).
From(sql.Table(ChildrenTable)).
Where(sql.NotNull(ChildrenColumn)),
),
)
},
)
}
// HasChildrenWith applies the HasEdge predicate on the "children" edge with a given conditions (other predicates).
func HasChildrenWith(preds ...predicate.Node) predicate.Node {
return predicate.Node(
func(s *sql.Selector) {
t1 := s.Table()
t2 := sql.Select(ChildrenColumn).From(sql.Table(ChildrenTable))
for _, p := range preds {
p(t2)
}
s.Where(sql.In(t1.C(FieldID), t2))
},
)
}
// And groups list of predicates with the AND operator between them.
func And(predicates ...predicate.Node) predicate.Node {
return predicate.Node(
func(s *sql.Selector) {
for _, p := range predicates {
p(s)
}
},
)
}
// Or groups list of predicates with the OR operator between them.
func Or(predicates ...predicate.Node) predicate.Node {
return predicate.Node(
func(s *sql.Selector) {
for i, p := range predicates {
if i > 0 {
s.Or()
}
p(s)
}
},
)
}
// Not applies the not operator on the given predicate.
func Not(p predicate.Node) predicate.Node {
return predicate.Node(
func(s *sql.Selector) {
p(s.Not())
},
)
}