Database Reference
In-Depth Information
As you can see, inserting data through the Mongo shell is straightforward.
The process of inserting data is extremely flexible, but you must adhere to some rules
when doing so. For example, the names of the keys while inserting documents have the
following limitations:
$ character must not be the first character in the key name.
Example: $tags
The
. ] character must not appear anywhere in the key
name. Example: ta.gs
The period [
_id is reserved for use as a primary key ID; although it
is not recommended, it can store anything unique as a value, such
as a string or an integer.
The name
Similarly, some restrictions apply when creating a collection. For example, the name
of a collection must adhere to the following rules:
The collection's name cannot exceed 128 characters.
An empty string (“ ”) cannot be used as a collection name.
The collection's name must start with either a letter or an
underscore.
system is reserved for MongoDB and cannot
The collection name
be used.
The collection's name cannot contain the “\0” null character.
Querying for Data
You've seen how to switch to your database and how to insert data; next, you will learn
how to query for data in your collection. Let's build on the preceding example and look at
all the possible ways to get a good clear view of your data in a given collection.
When querying your data, you have an extraordinary range of options, operators,
expressions, filters, and so on available to you. We will spend the next few sections
reviewing these options.
Note
The find() function provides the easiest way to retrieve data from multiple
documents within one of your collections. This function is one that you will be
using often.
 
 
Search WWH ::




Custom Search