Real-time web apps with mongodb and nodejs
<p>I've been thinking about how to make a real-time web application using nodejs/socket.io/mongodb. The idea is pretty similar to google docs, where objects edited on a page are emitted and rerendered on all client browsers.</p>
<p>What is the best way to go about doing this? From what I've read I can think of 3 ways:</p>
<h3>1) Using mongodb oplogs</h3>
<p>Add a 'listener' to mongodb collections, rerender parts of page whenever changes are made to collection (cons: slow?)</p>
<h3>2) Using local json</h3>
<p>Retrieve mongodb data into json file, use fs to edit, save to mongodb and delete json when done (cons: cumbersome to have extra layer between database and actual app)</p>
<h3>3) Using purely socket.io</h3>
<p>Rerender without storing, save only after all changes have been made (cons: files probably not rendered correctly in all browsers)</p>
<p>Is there a better way to achieve this? (How does google docs work anyway?) Would really appreciate any help anyone can offer!</p>