// SetTopPost sets the 'TopPost' relationship for provided input 'models'.
SetTopPost sets the 'TopPost' relationship for provided input 'models'.
// SetTopPost sets the ' TopPost ' relationship for provided input ' models ' .
func (b *_Blogs) SetTopPost(ctx context.Context, db database.DB, model *Blog, relation *Post) error {
	if model == nil {
		return errors.Wrap(query.ErrNoModels, "provided nil model")
	}
	if model.IsPrimaryKeyZero() {
		return errors.Wrap(mapping.ErrFieldValue, "model's: 'Blog' primary key value has zero value")
	}
	relationField, err := b.Model.RelationByIndex(4)
	if err != nil {
		return err
	}
	q := query.NewScope(b.Model, model)
	if relation.IsPrimaryKeyZero() {
		return errors.Wrap(mapping.ErrFieldValue, "relation 'TopPost' 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 ( b * _Blogs ) SetTopPost ( ctx context . Context , db database . DB , model * Blog , relation * Post ) error { if model == nil { return errors . Wrap ( query . ErrNoModels , " " ) } if model . IsPrimaryKeyZero ( ) { return errors . Wrap ( mapping . ErrFieldValue , " " ) } relationField , err := b . Model . RelationByIndex ( 4 ) if err != nil { return err } q := query . NewScope ( b . 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 ) }
SetTopPost sets the 'TopPost' relationship for provided input 'models'.
SetTopPost sets the ' TopPost ' relationship for provided input ' models ' .
// Check if primary key has zero value.