I try to use Datatable to show data of Firestore.
firestore.collection('users').onSnapshot(function(snapshots) {
if (!snapshots.empty) {
let data = [];
snapshots.forEach(function(doc) {
data.push([doc.id, doc.data().name, doc.data().score, moment(doc.data().createdAt.toDate()).format("YYYY-MM-DD HH:mm")])
})
$("#users_table").DataTable({
data: data,
"responsive": true, "lengthChange": false, "autoWidth": false,
"buttons": ["copy", "csv", "excel", "pdf", "print"]
}).buttons().container().appendTo('#users_table_wrapper .col-md-6:eq(0)');
} else {
}
});
However, this code is not reasonable because it imports all the data from the users collection at once.
I want to import Firestore's data by page like ajax api call.
https://datatables.net/examples/server_side/pipeline.html
Is there any good way to call and display Firestore's data by page using Datatable?