// Create adds a new post.
Create adds a new post.
// Create adds a new post .
func (pr *PostRepository) Create(ctx context.Context, p *post.Post) error {
	q := `
	INSERT INTO posts (body, user_id, created_at, updated_at)
		VALUES ($1, $2, $3, $4)
		RETURNING id;
	`
	stmt, err := pr.Data.DB.PrepareContext(ctx, q)
	if err != nil {
		return err
	}
	defer stmt.Close()
	row := stmt.QueryRowContext(ctx, p.Body, p.UserID, time.Now(), time.Now())
	err = row.Scan(&p.ID)
	if err != nil {
		return err
	}
	return nil
}
func ( pr * PostRepository ) Create ( ctx context . Context , p * post . Post ) error { q := `
	INSERT INTO posts (body, user_id, created_at, updated_at)
		VALUES ($1, $2, $3, $4)
		RETURNING id;
	` stmt , err := pr . Data . DB . PrepareContext ( ctx , q ) if err != nil { return err } defer stmt . Close ( ) row := stmt . QueryRowContext ( ctx , p . Body , p . UserID , time . Now ( ) , time . Now ( ) ) err = row . Scan ( & p . ID ) if err != nil { return err } return nil }
Create adds a new post.
Create adds a new post .