// AddComments adds the 'Comments' relationship for provided input 'models'.
AddComments adds the 'Comments' relationship for provided input 'models'.
// AddComments adds the ' Comments ' relationship for provided input ' models ' .
func (p *_Posts) AddComments(ctx context.Context, db database.DB, model *Post, relations ...*Comment) error {
	if model == nil {
		return errors.Wrap(query.ErrNoModels, "provided nil model")
	}
	if len(relations) == 0 {
		return errors.Wrap(query.ErrNoModels, "no relation models provided")
	}
	relationField, err := p.Model.RelationByIndex(6)
	if err != nil {
		return err
	}
	relationModels := make([]mapping.Model, len(relations))
	for i := range relations {
		relationModels[i] = relations[i]
	}
	q := query.NewScope(p.Model, model)
	relationAdder, ok := db.(database.QueryRelationAdder)
	if !ok {
		return errors.WrapDetf(query.ErrInternal, "DB doesn't implement QueryRelationAdder interface - %T", db)
	}
	return relationAdder.QueryAddRelations(ctx, q, relationField, relationModels...)
}
func ( p * _Posts ) AddComments ( ctx context . Context , db database . DB , model * Post , relations ... * Comment ) error { if model == nil { return errors . Wrap ( query . ErrNoModels , " " ) } if len ( relations ) == 0 { return errors . Wrap ( query . ErrNoModels , " " ) } relationField , err := p . Model . RelationByIndex ( 6 ) if err != nil { return err } relationModels := make ( [ ] mapping . Model , len ( relations ) ) for i := range relations { relationModels [ i ] = relations [ i ] } q := query . NewScope ( p . Model , model ) relationAdder , ok := db . ( database . QueryRelationAdder ) if ! ok { return errors . WrapDetf ( query . ErrInternal , " " , db ) } return relationAdder . QueryAddRelations ( ctx , q , relationField , relationModels ... ) }
AddComments adds the 'Comments' relationship for provided input 'models'.
AddComments adds the ' Comments ' relationship for provided input ' models ' .