Bỏ qua, đến nội dung

Tham chiếu API

Endpoint chính

{collection}:export

Method: POST

Xuất dữ liệu collection ra file Excel (XLSX). Response là binary stream.

Request parameters:

Tham sốKiểuBắt buộcMô tả
columnsarrayDanh sách cột cần xuất (field name + tiêu đề hiển thị)
filterobjectKhôngBộ lọc dữ liệu (giống list filter)
sortarrayKhôngThứ tự sắp xếp
appendsstring[]KhôngRelation fields cần kèm theo
titlestringKhôngTiêu đề file Excel (tên sheet / filename)

Response: Binary XLSX stream (Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet).

Luồng xử lý server

  1. Server nhận request, acquire global mutex (chỉ 1 export chạy cùng lúc).
  2. XlsxExporter query dữ liệu từ DB theo filter, sort, appends.
  3. Format dữ liệu theo cấu hình columns (tên cột, format number/date).
  4. Resolve relation fields thành giá trị hiển thị.
  5. Build file XLSX binary.
  6. Release mutex, trả binary stream về client.

Global mutex

Plugin sử dụng async-mutex để serialize export requests:

Đặc điểmMô tả
Phạm viToàn cục (toàn bộ server instance)
Mục đíchNgăn nhiều export chạy đồng thời gây quá tải RAM/CPU
Hành vi khi bậnRequest chờ đến khi mutex được release

XlsxExporter

Class chịu trách nhiệm tạo file XLSX:

BướcMô tả
QueryĐọc dữ liệu từ DB theo filter, sort, appends
FormatMap dữ liệu theo cấu hình columns (tên cột, format number/date)
RelationsResolve relation fields (belongsTo, hasMany) thành giá trị hiển thị
Build XLSXSử dụng thư viện xlsx / node-xlsx để tạo file Excel binary
StreamTrả binary stream về client qua HTTP response

ACL

QuyềnMô tả
exportQuyền riêng biệt, được thêm vào admin role khi install
configureFieldsallowConfigureFields: true — cho phép cấu hình field-level access