Storing (possible millions) of comments in a single collection?

I think this is reasonable. However I’d like to point out that with regard to the _id field, ObjectId is just the default auto-generated value that is unlikely to be duplicated. If you need to, you can use a custom _id field (and thus would perhaps create a more informative reference in the resourceId field).

Using a custom _id field would be an advantage for some application, since e.g. if you know the primary key for a collection and have a method to generate one, your app won’t be able to insert two identical documents, since the_id field is uniquely indexed.

Best regards
Kevin

1 Like