Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>To address each question separately:</p> <ol> <li><p>No, that is not true anymore. Older versions of MongoDB did not have journaling, but current versions do, and from v. 2, it is activated by default. However, you should use a <code>SafeMode</code> on the driver level which ensures that the communication between driver and database were successful.</p></li> <li><p>Embedded posts and threads might not be the best choice. We've built a similar thing, and we're using a flat collection where each post stores the ParentId and the ParentThreadId. There are pros and cons to embedding, but the arguments for our decision were:</p> <p>a) Often times, we only want to fetch the most recent comments site-wide or <em>n</em> most recent comments in a given thread, both of which can't really be done using embedded documents. </p> <p>b) If you have a lot of people writing about the same topic at the same time, you need to be careful about concurrency. This can be solved, but we felt safer using different objects that can't really interfere, even if you make mistakes</p> <p>c) As Joe points out, you'll have to handle full-text search in a different system.</p></li> <li><p>Embedded documents are not so well suited if you have a lot of updates, because the container (the collection item that contains the embedded objects) will grow. When it grows, MongoDB will have to reallocate it, which may take longer and fragments data.</p> <p>3(a). For status updates of friends, using a fan-out strategy makes sense. I <a href="https://stackoverflow.com/questions/8163850/how-to-create-a-feed-of-files-from-people-that-a-user-is-following/8164580#8164580">answered a similar question yesterday</a>.</p></li> <li><p>Don't use auto-increment numbers. This is a flawed design by default, because it does not really work that well in a distributed environment. For the db, it doesn't make a difference whether it stores a <code>int</code> with value <code>0x00000001</code> or one with value <code>0xfa9ac7335</code>. There's no point in keeping the numbers small. I'd go with the Mongo <code>ObjectId</code> or <code>Guid</code>/<code>UUID</code>. The former also contains a timestamp btw.</p></li> <li><p>I haven't used mongoose, but in general, there are the typical strategies of pessimistic and optimistic locks.</p></li> </ol>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload