I am just beginning to learn using Backbone.js. Previously I have used a web framework built on top of Node.js to handle all the routes and responses. With Backbone is the possibility of a SPA (single page application).
I believe my question is related to this one: Account for Backbone.js pushState routes with node.js express server? (a question of express.js + backbone).
In which the code is given:
app.get('/', function(req, res) {
// Trigger the routes 'domain.com' and 'domain.com/#/about'
// Here render the base of your application
});
app.get('/about', function (req, res) {
// Trigger the toure 'domain.com/about'
// Here use templates to generate the right view and render
});
From using node web frameworks I have usually not used json requests to get data, but have queried the database in the route closure. Is the job of node.js (in a node+backbone environment) simply to serve up the backbone page and not query the database? So it simply directs clients to the specified backbone.js template without passing any data, and backbone takes over?
So if I wanted to display all book models (example.com/books) for instance, would I just send the user via node to that url, and backbone will take care of querying the database (with the model, of course)? What would that code look like?
Most of the backbone tutorials I've seen have dealt with external api's. Thanks!