View gist:2178987
MongoDB provides a Javascript shell. But Javascript is no fun without underscore.js | |
Turned out its straight forward to use underscore.js while scripting mongodb. | |
Here are the steps. | |
1) Use underscore to write your db script file (say my_commands.js) | |
E.g: _.each(db.dbname.find().toArray(), function(itm) { ... }) |
View gist:3354438
This Gist is for the case where your html is generated on the server side, but you still want to use Backbone to manage | |
the incremental user actions. The idea is to parse the already rendered DOM and create the model / collection on the | |
first time, hence we can still follow the Backbone pattern to update models and the bindings reflect view and update server etc. | |
Lets do step by step for the infamous TODO application: | |
Step 1) Add a function dom2coll() to the AppView that will parse the rendered DOM and convert to data. | |
dom2coll: function() { | |
// To update model/view from already rendered DOM from backend. |