// SetBlog sets the 'Blog' relationship for provided input 'models'.
SetBlog sets the 'Blog' relationship for provided input 'models'.
// SetBlog sets the ' Blog ' relationship for provided input ' models ' .
func (p *_Posts) SetBlog(ctx context.Context, db database.DB, model *Post, relation *Blog) error {
	if model == nil {
		return errors.Wrap(query.ErrNoModels, "provided nil model")
	}
	if model.IsPrimaryKeyZero() {
		return errors.Wrap(mapping.ErrFieldValue, "model's: 'Post' primary key value has zero value")
	}
	relationField, err := p.Model.RelationByIndex(4)
	if err != nil {
		return err
	}
	q := query.NewScope(p.Model, model)
	if relation.IsPrimaryKeyZero() {
		return errors.Wrap(mapping.ErrFieldValue, "relation 'Blog' model has zero value primary field")
	}
	relationSetter, ok := db.(database.QueryRelationSetter)
	if !ok {
		return errors.WrapDetf(query.ErrInternal, "DB doesn't implement QueryRelationSetter interface: %T", db)
	}
	return relationSetter.QuerySetRelations(ctx, q, relationField, relation)
}
func ( p * _Posts ) SetBlog ( ctx context . Context , db database . DB , model * Post , relation * Blog ) error { if model == nil { return errors . Wrap ( query . ErrNoModels , " " ) } if model . IsPrimaryKeyZero ( ) { return errors . Wrap ( mapping . ErrFieldValue , " " ) } relationField , err := p . Model . RelationByIndex ( 4 ) if err != nil { return err } q := query . NewScope ( p . Model , model ) if relation . IsPrimaryKeyZero ( ) { return errors . Wrap ( mapping . ErrFieldValue , " " ) } relationSetter , ok := db . ( database . QueryRelationSetter ) if ! ok { return errors . WrapDetf ( query . ErrInternal , " " , db ) } return relationSetter . QuerySetRelations ( ctx , q , relationField , relation ) }
SetBlog sets the 'Blog' relationship for provided input 'models'.
SetBlog sets the ' Blog ' relationship for provided input ' models ' .
// Check if primary key has zero value.