Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TransferCSVFileChunked ¶
func TransferCSVFileChunked[T any]( ginContext *gin.Context, dbconn *gorm.DB, query, filename string, chunkSize int, ) error
TransferCSVFileChunked is a function that responses a large csv file . The function works as follows: 1. Initializes the chunker and cursor. 2. Writes the header and the label of the CSV file. 3. Fetches the data from the cursor and writes the data in chunks. 4. Resets the writer. Need to gin.Context and gorm.DB to use this function. The fetchSize is the number of rows to be fetched at a time.
Types ¶
type Chunker ¶
func (*Chunker[T]) ResetWriter ¶
func (chunker *Chunker[T]) ResetWriter()
ResetWriter resets the csv writer.
func (*Chunker[T]) SetHeader ¶
SetHeader sets the response header for the CSV file. The filename is the name of the file to be downloaded. The default encoding is UTF-8. Transfer-Encoding is set to chunked.
func (*Chunker[T]) WriteChunk ¶
WriteChunk writes the data in chunks.
func (*Chunker[T]) WriteCsvLabel ¶
func (chunker *Chunker[T]) WriteCsvLabel()
WriteCsvLabel writes the Label of the CSV data.