Note that there are some explanatory texts on larger screens.

plurals
  1. POIs it a bad practice to use the "." symbol in Mongodb collection name?
    primarykey
    data
    text
    <p>I have a quite big web application. The application is split in multiple modules. Each modules can create multiple collections in the Mongodb database.</p> <p>Since each modules can create collections, There is a possibility to have collision between them so I'm currently trying to "namespace" my collections in a elegant way.</p> <p>Here is an example of what <strong>I would like to do</strong>:</p> <p><em>Module1 creates these collections:</em></p> <pre><code>module1.items module1.employees </code></pre> <p><em>Module2 creates these collections:</em></p> <pre><code>module2.items // Avoid collision with module1 module2.animals </code></pre> <p>Here is an example of what <strong>I would like to avoid</strong>:</p> <p><em>Module1 creates these collections:</em></p> <pre><code>module1items module1employees </code></pre> <p><em>Module2 creates these collections:</em></p> <pre><code>module2items // Avoid collision with module1 module2animals </code></pre> <p>Now I wonder if it is a bad pratice to use "." in the collection name. Usually, the "." is used to split the database name from the collections name like <code>db.mydatabase.mycollection</code> so I am concerned about possible bugs I might encounter if I use the "." method to namespace my collection name.</p> <p>[EDIT]</p> <p>Here is a quote I found on the mongodb website:</p> <p><em>For an example <strong>acme.users</strong> namespace, <strong>acme</strong> is the database name and <strong>users</strong> is the collection name. Period characters can occur in collection names, so that <strong>acme.user.history</strong> is a valid namespace, with <strong>acme</strong> as the database name, and <strong>user.history</strong> as the collection name.</em> <a href="http://docs.mongodb.org/manual/faq/developers/" rel="nofollow noreferrer">Reference</a></p> <p>Adding that to <a href="https://stackoverflow.com/a/16568284/613568">Stephane Godbillon's answer</a> (mentioning gridFS), I now feel quite safe about using that naming convention. Now I just hope that the ODM I use (mongoose) will not cause any problem :).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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