Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: MongoDB ObjectID

by 1nickt (Canon)
on Oct 12, 2019 at 20:55 UTC ( [id://11107385]=note: print w/replies, xml ) Need Help??


in reply to MongoDB ObjectID

Hi, good choice of tools!

"Should I serialize every ObjectID on the way to HTML"

Yes. You should pass the data for your table to your template as a hashref or arrayref of arrayrefs, serialized to JSON. (And make calls to your Dancer app passing JSON representing SQL ops.) It'll be a long string (or you use paging).

Then use a front-end framework for building and displaying the actual HTML table. I have had great success using the DataTable jQuery plugin with Dancer2 and TT2. It has great support for autoscrolling and callbacks for making cell data click into other things. There's an add-on that provides interactive CRUD ops to your server via Ajax, and also of possible note is DataTables (and maybe Web::Library::DataTables).

Hope this helps! Glad to help with Dancer2 questions here!


The way forward always starts with a minimal test.

Replies are listed 'Best First'.
Re^2: MongoDB ObjectID
by betacentauri (Sexton) on Oct 12, 2019 at 21:15 UTC
    Wow, thank you very much! What a juicy answer! Please, please, elaborate about "or you use paging".

      Depending on the framework you use in the browser to display the table, you may have too many rows in your table to transmit all at once. If so, you send a subset of the rows to be displayed, along with the data that the front-end JS needs to fetch the next "page" of rows (basically just a starting row ID and an offset).

      FWIW you can comfortably avoid paging and preload up to about 10,000 rows in a JSON object that you pass to the browser via your template layer, and DataTables will handle it smoothly (it's pretty nifty and only adds the row into the DOM when the user scrolls it into view).

      Hope this helps!


      The way forward always starts with a minimal test.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11107385]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2024-04-19 14:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found