snapshot of https://github.com/ent/ent.git (master, 2026-09-15; blobs > 131072B omitted)
This commit is contained in:
432
entc/integration/cascadelete/ent/post/mutation.go
Normal file
432
entc/integration/cascadelete/ent/post/mutation.go
Normal file
@@ -0,0 +1,432 @@
|
||||
// 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.
|
||||
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package post
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/entc/integration/cascadelete/ent/predicate"
|
||||
)
|
||||
|
||||
// Mutation represents an operation that mutates the Post nodes in the graph.
|
||||
type Mutation struct {
|
||||
op ent.Op
|
||||
typ string
|
||||
text *string
|
||||
clearedFields map[string]struct{}
|
||||
author *int
|
||||
clearedauthor bool
|
||||
comments map[int]struct{}
|
||||
removedcomments map[int]struct{}
|
||||
clearedcomments bool
|
||||
predicates []predicate.Post
|
||||
}
|
||||
|
||||
// NewMutation creates a new Mutation for the Post entity.
|
||||
func NewMutation(op ent.Op) *Mutation {
|
||||
return &Mutation{
|
||||
op: op,
|
||||
typ: "Post",
|
||||
clearedFields: make(map[string]struct{}),
|
||||
}
|
||||
}
|
||||
|
||||
// Predicates returns the list of predicates set on the mutation.
|
||||
func (m *Mutation) Predicates() []predicate.Post {
|
||||
return m.predicates
|
||||
}
|
||||
|
||||
// SetText sets the "text" field.
|
||||
func (m *Mutation) SetText(s string) {
|
||||
m.text = &s
|
||||
}
|
||||
|
||||
// Text returns the value of the "text" field in the mutation.
|
||||
func (m *Mutation) Text() (r string, exists bool) {
|
||||
v := m.text
|
||||
if v == nil {
|
||||
return
|
||||
}
|
||||
return *v, true
|
||||
}
|
||||
|
||||
// ResetText resets all changes to the "text" field.
|
||||
func (m *Mutation) ResetText() {
|
||||
m.text = nil
|
||||
}
|
||||
|
||||
// SetAuthorID sets the "author_id" field.
|
||||
func (m *Mutation) SetAuthorID(i int) {
|
||||
m.author = &i
|
||||
}
|
||||
|
||||
// AuthorID returns the value of the "author_id" field in the mutation.
|
||||
func (m *Mutation) AuthorID() (r int, exists bool) {
|
||||
v := m.author
|
||||
if v == nil {
|
||||
return
|
||||
}
|
||||
return *v, true
|
||||
}
|
||||
|
||||
// ClearAuthorID clears the value of the "author_id" field.
|
||||
func (m *Mutation) ClearAuthorID() {
|
||||
m.author = nil
|
||||
m.clearedFields[FieldAuthorID] = struct{}{}
|
||||
}
|
||||
|
||||
// AuthorIDCleared returns if the "author_id" field was cleared in this mutation.
|
||||
func (m *Mutation) AuthorIDCleared() bool {
|
||||
_, ok := m.clearedFields[FieldAuthorID]
|
||||
return ok
|
||||
}
|
||||
|
||||
// ResetAuthorID resets all changes to the "author_id" field.
|
||||
func (m *Mutation) ResetAuthorID() {
|
||||
m.author = nil
|
||||
delete(m.clearedFields, FieldAuthorID)
|
||||
}
|
||||
|
||||
// ClearAuthor clears the "author" edge to the User entity.
|
||||
func (m *Mutation) ClearAuthor() {
|
||||
m.clearedauthor = true
|
||||
m.clearedFields[FieldAuthorID] = struct{}{}
|
||||
}
|
||||
|
||||
// AuthorCleared reports if the "author" edge to the User entity was cleared.
|
||||
func (m *Mutation) AuthorCleared() bool {
|
||||
return m.AuthorIDCleared() || m.clearedauthor
|
||||
}
|
||||
|
||||
// AuthorIDs returns the "author" edge IDs in the mutation.
|
||||
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
|
||||
// AuthorID instead. It exists only for internal usage by the builders.
|
||||
func (m *Mutation) AuthorIDs() (ids []int) {
|
||||
if id := m.author; id != nil {
|
||||
ids = append(ids, *id)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// ResetAuthor resets all changes to the "author" edge.
|
||||
func (m *Mutation) ResetAuthor() {
|
||||
m.author = nil
|
||||
m.clearedauthor = false
|
||||
}
|
||||
|
||||
// AddCommentIDs adds the "comments" edge to the Comment entity by ids.
|
||||
func (m *Mutation) AddCommentIDs(ids ...int) {
|
||||
if m.comments == nil {
|
||||
m.comments = make(map[int]struct{})
|
||||
}
|
||||
for i := range ids {
|
||||
m.comments[ids[i]] = struct{}{}
|
||||
}
|
||||
}
|
||||
|
||||
// ClearComments clears the "comments" edge to the Comment entity.
|
||||
func (m *Mutation) ClearComments() {
|
||||
m.clearedcomments = true
|
||||
}
|
||||
|
||||
// CommentsCleared reports if the "comments" edge to the Comment entity was cleared.
|
||||
func (m *Mutation) CommentsCleared() bool {
|
||||
return m.clearedcomments
|
||||
}
|
||||
|
||||
// RemoveCommentIDs removes the "comments" edge to the Comment entity by IDs.
|
||||
func (m *Mutation) RemoveCommentIDs(ids ...int) {
|
||||
if m.removedcomments == nil {
|
||||
m.removedcomments = make(map[int]struct{})
|
||||
}
|
||||
for i := range ids {
|
||||
delete(m.comments, ids[i])
|
||||
m.removedcomments[ids[i]] = struct{}{}
|
||||
}
|
||||
}
|
||||
|
||||
// RemovedComments returns the removed IDs of the "comments" edge to the Comment entity.
|
||||
func (m *Mutation) RemovedCommentsIDs() (ids []int) {
|
||||
for id := range m.removedcomments {
|
||||
ids = append(ids, id)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// CommentsIDs returns the "comments" edge IDs in the mutation.
|
||||
func (m *Mutation) CommentsIDs() (ids []int) {
|
||||
for id := range m.comments {
|
||||
ids = append(ids, id)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// ResetComments resets all changes to the "comments" edge.
|
||||
func (m *Mutation) ResetComments() {
|
||||
m.comments = nil
|
||||
m.clearedcomments = false
|
||||
m.removedcomments = nil
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the Mutation builder.
|
||||
func (m *Mutation) Where(ps ...predicate.Post) {
|
||||
m.predicates = append(m.predicates, ps...)
|
||||
}
|
||||
|
||||
// WhereP appends storage-level predicates to the Mutation builder. Using this method,
|
||||
// users can use type-assertion to append predicates that do not depend on any generated package.
|
||||
func (m *Mutation) WhereP(ps ...func(*sql.Selector)) {
|
||||
p := make([]predicate.Post, len(ps))
|
||||
for i := range ps {
|
||||
p[i] = ps[i]
|
||||
}
|
||||
m.Where(p...)
|
||||
}
|
||||
|
||||
// Op returns the operation name.
|
||||
func (m *Mutation) Op() ent.Op {
|
||||
return m.op
|
||||
}
|
||||
|
||||
// SetOp allows setting the mutation operation.
|
||||
func (m *Mutation) SetOp(op ent.Op) {
|
||||
m.op = op
|
||||
}
|
||||
|
||||
// Type returns the node type of this mutation (Post).
|
||||
func (m *Mutation) Type() string {
|
||||
return m.typ
|
||||
}
|
||||
|
||||
// Fields returns all fields that were changed during this mutation. Note that in
|
||||
// order to get all numeric fields that were incremented/decremented, call
|
||||
// AddedFields().
|
||||
func (m *Mutation) Fields() []string {
|
||||
fields := make([]string, 0, 2)
|
||||
if m.text != nil {
|
||||
fields = append(fields, FieldText)
|
||||
}
|
||||
if m.author != nil {
|
||||
fields = append(fields, FieldAuthorID)
|
||||
}
|
||||
return fields
|
||||
}
|
||||
|
||||
// Field returns the value of a field with the given name. The second boolean
|
||||
// return value indicates that this field was not set, or was not defined in the
|
||||
// schema.
|
||||
func (m *Mutation) Field(name string) (ent.Value, bool) {
|
||||
switch name {
|
||||
case FieldText:
|
||||
return m.Text()
|
||||
case FieldAuthorID:
|
||||
return m.AuthorID()
|
||||
}
|
||||
return nil, false
|
||||
}
|
||||
|
||||
// OldField returns the old value of the field from the database. An error is
|
||||
// returned if the mutation operation is not UpdateOne, or the query to the
|
||||
// database failed.
|
||||
func (m *Mutation) OldField(ctx context.Context, name string) (ent.Value, error) {
|
||||
return nil, fmt.Errorf("unknown Post field %s", name)
|
||||
}
|
||||
|
||||
// SetField sets the value of a field with the given name. It returns an error if
|
||||
// the field is not defined in the schema, or if the type mismatched the field
|
||||
// type.
|
||||
func (m *Mutation) SetField(name string, value ent.Value) error {
|
||||
switch name {
|
||||
case FieldText:
|
||||
v, ok := value.(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||
}
|
||||
m.SetText(v)
|
||||
return nil
|
||||
case FieldAuthorID:
|
||||
v, ok := value.(int)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||
}
|
||||
m.SetAuthorID(v)
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("unknown Post field %s", name)
|
||||
}
|
||||
|
||||
// AddedFields returns all numeric fields that were incremented/decremented during
|
||||
// this mutation.
|
||||
func (m *Mutation) AddedFields() []string {
|
||||
var fields []string
|
||||
return fields
|
||||
}
|
||||
|
||||
// AddedField returns the numeric value that was incremented/decremented on a field
|
||||
// with the given name. The second boolean return value indicates that this field
|
||||
// was not set, or was not defined in the schema.
|
||||
func (m *Mutation) AddedField(name string) (ent.Value, bool) {
|
||||
switch name {
|
||||
}
|
||||
return nil, false
|
||||
}
|
||||
|
||||
// AddField adds the value to the field with the given name. It returns an error if
|
||||
// the field is not defined in the schema, or if the type mismatched the field
|
||||
// type.
|
||||
func (m *Mutation) AddField(name string, value ent.Value) error {
|
||||
switch name {
|
||||
}
|
||||
return fmt.Errorf("unknown Post numeric field %s", name)
|
||||
}
|
||||
|
||||
// ClearedFields returns all nullable fields that were cleared during this
|
||||
// mutation.
|
||||
func (m *Mutation) ClearedFields() []string {
|
||||
var fields []string
|
||||
if m.FieldCleared(FieldAuthorID) {
|
||||
fields = append(fields, FieldAuthorID)
|
||||
}
|
||||
return fields
|
||||
}
|
||||
|
||||
// FieldCleared returns a boolean indicating if a field with the given name was
|
||||
// cleared in this mutation.
|
||||
func (m *Mutation) FieldCleared(name string) bool {
|
||||
_, ok := m.clearedFields[name]
|
||||
return ok
|
||||
}
|
||||
|
||||
// ClearField clears the value of the field with the given name. It returns an
|
||||
// error if the field is not defined in the schema.
|
||||
func (m *Mutation) ClearField(name string) error {
|
||||
switch name {
|
||||
case FieldAuthorID:
|
||||
m.ClearAuthorID()
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("unknown Post nullable field %s", name)
|
||||
}
|
||||
|
||||
// ResetField resets all changes in the mutation for the field with the given name.
|
||||
// It returns an error if the field is not defined in the schema.
|
||||
func (m *Mutation) ResetField(name string) error {
|
||||
switch name {
|
||||
case FieldText:
|
||||
m.ResetText()
|
||||
return nil
|
||||
case FieldAuthorID:
|
||||
m.ResetAuthorID()
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("unknown Post field %s", name)
|
||||
}
|
||||
|
||||
// AddedEdges returns all edge names that were set/added in this mutation.
|
||||
func (m *Mutation) AddedEdges() []string {
|
||||
edges := make([]string, 0, 2)
|
||||
if m.author != nil {
|
||||
edges = append(edges, EdgeAuthor)
|
||||
}
|
||||
if m.comments != nil {
|
||||
edges = append(edges, EdgeComments)
|
||||
}
|
||||
return edges
|
||||
}
|
||||
|
||||
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
|
||||
// name in this mutation.
|
||||
func (m *Mutation) AddedIDs(name string) []ent.Value {
|
||||
switch name {
|
||||
case EdgeAuthor:
|
||||
if id := m.author; id != nil {
|
||||
return []ent.Value{*id}
|
||||
}
|
||||
case EdgeComments:
|
||||
ids := make([]ent.Value, 0, len(m.comments))
|
||||
for id := range m.comments {
|
||||
ids = append(ids, id)
|
||||
}
|
||||
return ids
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// RemovedEdges returns all edge names that were removed in this mutation.
|
||||
func (m *Mutation) RemovedEdges() []string {
|
||||
edges := make([]string, 0, 2)
|
||||
if m.removedcomments != nil {
|
||||
edges = append(edges, EdgeComments)
|
||||
}
|
||||
return edges
|
||||
}
|
||||
|
||||
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
|
||||
// the given name in this mutation.
|
||||
func (m *Mutation) RemovedIDs(name string) []ent.Value {
|
||||
switch name {
|
||||
case EdgeComments:
|
||||
ids := make([]ent.Value, 0, len(m.removedcomments))
|
||||
for id := range m.removedcomments {
|
||||
ids = append(ids, id)
|
||||
}
|
||||
return ids
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// ClearedEdges returns all edge names that were cleared in this mutation.
|
||||
func (m *Mutation) ClearedEdges() []string {
|
||||
edges := make([]string, 0, 2)
|
||||
if m.clearedauthor {
|
||||
edges = append(edges, EdgeAuthor)
|
||||
}
|
||||
if m.clearedcomments {
|
||||
edges = append(edges, EdgeComments)
|
||||
}
|
||||
return edges
|
||||
}
|
||||
|
||||
// EdgeCleared returns a boolean which indicates if the edge with the given name
|
||||
// was cleared in this mutation.
|
||||
func (m *Mutation) EdgeCleared(name string) bool {
|
||||
switch name {
|
||||
case EdgeAuthor:
|
||||
return m.clearedauthor
|
||||
case EdgeComments:
|
||||
return m.clearedcomments
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// ClearEdge clears the value of the edge with the given name. It returns an error
|
||||
// if that edge is not defined in the schema.
|
||||
func (m *Mutation) ClearEdge(name string) error {
|
||||
switch name {
|
||||
case EdgeAuthor:
|
||||
m.ClearAuthor()
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("unknown Post unique edge %s", name)
|
||||
}
|
||||
|
||||
// ResetEdge resets all changes to the edge with the given name in this mutation.
|
||||
// It returns an error if the edge is not defined in the schema.
|
||||
func (m *Mutation) ResetEdge(name string) error {
|
||||
switch name {
|
||||
case EdgeAuthor:
|
||||
m.ResetAuthor()
|
||||
return nil
|
||||
case EdgeComments:
|
||||
m.ResetComments()
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("unknown Post edge %s", name)
|
||||
}
|
||||
118
entc/integration/cascadelete/ent/post/post.go
Normal file
118
entc/integration/cascadelete/ent/post/post.go
Normal file
@@ -0,0 +1,118 @@
|
||||
// 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.
|
||||
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package post
|
||||
|
||||
import (
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
)
|
||||
|
||||
const (
|
||||
// Label holds the string label denoting the post type in the database.
|
||||
Label = "post"
|
||||
// FieldID holds the string denoting the id field in the database.
|
||||
FieldID = "id"
|
||||
// FieldText holds the string denoting the text field in the database.
|
||||
FieldText = "text"
|
||||
// FieldAuthorID holds the string denoting the author_id field in the database.
|
||||
FieldAuthorID = "author_id"
|
||||
// EdgeAuthor holds the string denoting the author edge name in mutations.
|
||||
EdgeAuthor = "author"
|
||||
// EdgeComments holds the string denoting the comments edge name in mutations.
|
||||
EdgeComments = "comments"
|
||||
// Table holds the table name of the post in the database.
|
||||
Table = "posts"
|
||||
// AuthorTable is the table that holds the author relation/edge.
|
||||
AuthorTable = "posts"
|
||||
// AuthorInverseTable is the table name for the User entity.
|
||||
// It exists in this package in order to avoid circular dependency with the "user" package.
|
||||
AuthorInverseTable = "users"
|
||||
// AuthorColumn is the table column denoting the author relation/edge.
|
||||
AuthorColumn = "author_id"
|
||||
// CommentsTable is the table that holds the comments relation/edge.
|
||||
CommentsTable = "comments"
|
||||
// CommentsInverseTable is the table name for the Comment entity.
|
||||
// It exists in this package in order to avoid circular dependency with the "comment" package.
|
||||
CommentsInverseTable = "comments"
|
||||
// CommentsColumn is the table column denoting the comments relation/edge.
|
||||
CommentsColumn = "post_id"
|
||||
)
|
||||
|
||||
// Columns holds all SQL columns for post fields.
|
||||
var Columns = []string{
|
||||
FieldID,
|
||||
FieldText,
|
||||
FieldAuthorID,
|
||||
}
|
||||
|
||||
// ValidColumn reports if the column name is valid (part of the table columns).
|
||||
func ValidColumn(column string) bool {
|
||||
for i := range Columns {
|
||||
if column == Columns[i] {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
var (
|
||||
// DefaultText holds the default value on creation for the "text" field.
|
||||
DefaultText string
|
||||
)
|
||||
|
||||
// OrderOption defines the ordering options for the Post queries.
|
||||
type OrderOption func(*sql.Selector)
|
||||
|
||||
// ByID orders the results by the id field.
|
||||
func ByID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByText orders the results by the text field.
|
||||
func ByText(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldText, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByAuthorID orders the results by the author_id field.
|
||||
func ByAuthorID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldAuthorID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByAuthorField orders the results by author field.
|
||||
func ByAuthorField(field string, opts ...sql.OrderTermOption) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborTerms(s, newAuthorStep(), sql.OrderByField(field, opts...))
|
||||
}
|
||||
}
|
||||
|
||||
// ByCommentsCount orders the results by comments count.
|
||||
func ByCommentsCount(opts ...sql.OrderTermOption) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborsCount(s, newCommentsStep(), opts...)
|
||||
}
|
||||
}
|
||||
|
||||
// ByComments orders the results by comments terms.
|
||||
func ByComments(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborTerms(s, newCommentsStep(), append([]sql.OrderTerm{term}, terms...)...)
|
||||
}
|
||||
}
|
||||
func newAuthorStep() *sqlgraph.Step {
|
||||
return sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(AuthorInverseTable, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, AuthorTable, AuthorColumn),
|
||||
)
|
||||
}
|
||||
func newCommentsStep() *sqlgraph.Step {
|
||||
return sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(CommentsInverseTable, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, CommentsTable, CommentsColumn),
|
||||
)
|
||||
}
|
||||
224
entc/integration/cascadelete/ent/post/where.go
Normal file
224
entc/integration/cascadelete/ent/post/where.go
Normal file
@@ -0,0 +1,224 @@
|
||||
// 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.
|
||||
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package post
|
||||
|
||||
import (
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/entc/integration/cascadelete/ent/predicate"
|
||||
)
|
||||
|
||||
// ID filters vertices based on their ID field.
|
||||
func ID(id int) predicate.Post {
|
||||
return predicate.Post(sql.FieldEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDEQ applies the EQ predicate on the ID field.
|
||||
func IDEQ(id int) predicate.Post {
|
||||
return predicate.Post(sql.FieldEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDNEQ applies the NEQ predicate on the ID field.
|
||||
func IDNEQ(id int) predicate.Post {
|
||||
return predicate.Post(sql.FieldNEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDIn applies the In predicate on the ID field.
|
||||
func IDIn(ids ...int) predicate.Post {
|
||||
return predicate.Post(sql.FieldIn(FieldID, ids...))
|
||||
}
|
||||
|
||||
// IDNotIn applies the NotIn predicate on the ID field.
|
||||
func IDNotIn(ids ...int) predicate.Post {
|
||||
return predicate.Post(sql.FieldNotIn(FieldID, ids...))
|
||||
}
|
||||
|
||||
// IDGT applies the GT predicate on the ID field.
|
||||
func IDGT(id int) predicate.Post {
|
||||
return predicate.Post(sql.FieldGT(FieldID, id))
|
||||
}
|
||||
|
||||
// IDGTE applies the GTE predicate on the ID field.
|
||||
func IDGTE(id int) predicate.Post {
|
||||
return predicate.Post(sql.FieldGTE(FieldID, id))
|
||||
}
|
||||
|
||||
// IDLT applies the LT predicate on the ID field.
|
||||
func IDLT(id int) predicate.Post {
|
||||
return predicate.Post(sql.FieldLT(FieldID, id))
|
||||
}
|
||||
|
||||
// IDLTE applies the LTE predicate on the ID field.
|
||||
func IDLTE(id int) predicate.Post {
|
||||
return predicate.Post(sql.FieldLTE(FieldID, id))
|
||||
}
|
||||
|
||||
// Text applies equality check predicate on the "text" field. It's identical to TextEQ.
|
||||
func Text(v string) predicate.Post {
|
||||
return predicate.Post(sql.FieldEQ(FieldText, v))
|
||||
}
|
||||
|
||||
// AuthorID applies equality check predicate on the "author_id" field. It's identical to AuthorIDEQ.
|
||||
func AuthorID(v int) predicate.Post {
|
||||
return predicate.Post(sql.FieldEQ(FieldAuthorID, v))
|
||||
}
|
||||
|
||||
// TextEQ applies the EQ predicate on the "text" field.
|
||||
func TextEQ(v string) predicate.Post {
|
||||
return predicate.Post(sql.FieldEQ(FieldText, v))
|
||||
}
|
||||
|
||||
// TextNEQ applies the NEQ predicate on the "text" field.
|
||||
func TextNEQ(v string) predicate.Post {
|
||||
return predicate.Post(sql.FieldNEQ(FieldText, v))
|
||||
}
|
||||
|
||||
// TextIn applies the In predicate on the "text" field.
|
||||
func TextIn(vs ...string) predicate.Post {
|
||||
return predicate.Post(sql.FieldIn(FieldText, vs...))
|
||||
}
|
||||
|
||||
// TextNotIn applies the NotIn predicate on the "text" field.
|
||||
func TextNotIn(vs ...string) predicate.Post {
|
||||
return predicate.Post(sql.FieldNotIn(FieldText, vs...))
|
||||
}
|
||||
|
||||
// TextGT applies the GT predicate on the "text" field.
|
||||
func TextGT(v string) predicate.Post {
|
||||
return predicate.Post(sql.FieldGT(FieldText, v))
|
||||
}
|
||||
|
||||
// TextGTE applies the GTE predicate on the "text" field.
|
||||
func TextGTE(v string) predicate.Post {
|
||||
return predicate.Post(sql.FieldGTE(FieldText, v))
|
||||
}
|
||||
|
||||
// TextLT applies the LT predicate on the "text" field.
|
||||
func TextLT(v string) predicate.Post {
|
||||
return predicate.Post(sql.FieldLT(FieldText, v))
|
||||
}
|
||||
|
||||
// TextLTE applies the LTE predicate on the "text" field.
|
||||
func TextLTE(v string) predicate.Post {
|
||||
return predicate.Post(sql.FieldLTE(FieldText, v))
|
||||
}
|
||||
|
||||
// TextContains applies the Contains predicate on the "text" field.
|
||||
func TextContains(v string) predicate.Post {
|
||||
return predicate.Post(sql.FieldContains(FieldText, v))
|
||||
}
|
||||
|
||||
// TextHasPrefix applies the HasPrefix predicate on the "text" field.
|
||||
func TextHasPrefix(v string) predicate.Post {
|
||||
return predicate.Post(sql.FieldHasPrefix(FieldText, v))
|
||||
}
|
||||
|
||||
// TextHasSuffix applies the HasSuffix predicate on the "text" field.
|
||||
func TextHasSuffix(v string) predicate.Post {
|
||||
return predicate.Post(sql.FieldHasSuffix(FieldText, v))
|
||||
}
|
||||
|
||||
// TextEqualFold applies the EqualFold predicate on the "text" field.
|
||||
func TextEqualFold(v string) predicate.Post {
|
||||
return predicate.Post(sql.FieldEqualFold(FieldText, v))
|
||||
}
|
||||
|
||||
// TextContainsFold applies the ContainsFold predicate on the "text" field.
|
||||
func TextContainsFold(v string) predicate.Post {
|
||||
return predicate.Post(sql.FieldContainsFold(FieldText, v))
|
||||
}
|
||||
|
||||
// AuthorIDEQ applies the EQ predicate on the "author_id" field.
|
||||
func AuthorIDEQ(v int) predicate.Post {
|
||||
return predicate.Post(sql.FieldEQ(FieldAuthorID, v))
|
||||
}
|
||||
|
||||
// AuthorIDNEQ applies the NEQ predicate on the "author_id" field.
|
||||
func AuthorIDNEQ(v int) predicate.Post {
|
||||
return predicate.Post(sql.FieldNEQ(FieldAuthorID, v))
|
||||
}
|
||||
|
||||
// AuthorIDIn applies the In predicate on the "author_id" field.
|
||||
func AuthorIDIn(vs ...int) predicate.Post {
|
||||
return predicate.Post(sql.FieldIn(FieldAuthorID, vs...))
|
||||
}
|
||||
|
||||
// AuthorIDNotIn applies the NotIn predicate on the "author_id" field.
|
||||
func AuthorIDNotIn(vs ...int) predicate.Post {
|
||||
return predicate.Post(sql.FieldNotIn(FieldAuthorID, vs...))
|
||||
}
|
||||
|
||||
// AuthorIDIsNil applies the IsNil predicate on the "author_id" field.
|
||||
func AuthorIDIsNil() predicate.Post {
|
||||
return predicate.Post(sql.FieldIsNull(FieldAuthorID))
|
||||
}
|
||||
|
||||
// AuthorIDNotNil applies the NotNil predicate on the "author_id" field.
|
||||
func AuthorIDNotNil() predicate.Post {
|
||||
return predicate.Post(sql.FieldNotNull(FieldAuthorID))
|
||||
}
|
||||
|
||||
// HasAuthor applies the HasEdge predicate on the "author" edge.
|
||||
func HasAuthor() predicate.Post {
|
||||
return predicate.Post(func(s *sql.Selector) {
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, AuthorTable, AuthorColumn),
|
||||
)
|
||||
sqlgraph.HasNeighbors(s, step)
|
||||
})
|
||||
}
|
||||
|
||||
// HasAuthorWith applies the HasEdge predicate on the "author" edge with a given conditions (other predicates).
|
||||
func HasAuthorWith(preds ...predicate.User) predicate.Post {
|
||||
return predicate.Post(func(s *sql.Selector) {
|
||||
step := newAuthorStep()
|
||||
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||
for _, p := range preds {
|
||||
p(s)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// HasComments applies the HasEdge predicate on the "comments" edge.
|
||||
func HasComments() predicate.Post {
|
||||
return predicate.Post(func(s *sql.Selector) {
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, CommentsTable, CommentsColumn),
|
||||
)
|
||||
sqlgraph.HasNeighbors(s, step)
|
||||
})
|
||||
}
|
||||
|
||||
// HasCommentsWith applies the HasEdge predicate on the "comments" edge with a given conditions (other predicates).
|
||||
func HasCommentsWith(preds ...predicate.Comment) predicate.Post {
|
||||
return predicate.Post(func(s *sql.Selector) {
|
||||
step := newCommentsStep()
|
||||
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||
for _, p := range preds {
|
||||
p(s)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// And groups predicates with the AND operator between them.
|
||||
func And(predicates ...predicate.Post) predicate.Post {
|
||||
return predicate.Post(sql.AndPredicates(predicates...))
|
||||
}
|
||||
|
||||
// Or groups predicates with the OR operator between them.
|
||||
func Or(predicates ...predicate.Post) predicate.Post {
|
||||
return predicate.Post(sql.OrPredicates(predicates...))
|
||||
}
|
||||
|
||||
// Not applies the not operator on the given predicate.
|
||||
func Not(p predicate.Post) predicate.Post {
|
||||
return predicate.Post(sql.NotPredicates(p))
|
||||
}
|
||||
Reference in New Issue
Block a user