Database Reference
In-Depth Information
First, let's list all the files in the database. We're not expecting any files to be in there
yet, but let's make sure. The list command lists the files in the database so far:
$ mongofiles list
connected to: 127.0.0.1
$
OK, so that probably wasn't very exciting. Keep in mind that mongofiles is a proof-
of-concept tool; it's probably not a tool you will use much with your own applications.
However, mongofiles is great for learning and testing. Once you create a file, you can use
the tool to explore the files and chunks that are created.
Let's kick things up a notch and the put command to add the dictionary file created
previously (remember: you can use any file that you like for this example):
$ mongofiles put /tmp/dictionary
connected to: 127.0.0.1
added file: { _id: ObjectId('51cb61b26487b3d8ce7af440'), filename: "/tmp/
dictionary", chunkSize: 262144, uploadDate: new Date(1372283314621), md5:
"40c0825855792bd20e8a2d515fe9c3e3", length: 4953699 }}}
done!
$
This example returns some useful information; however, let's double-check the
information it shows by confirming that the file is there. Do so by rerunning the list
command:
$ mongofiles list
connected to: 127.0.0.1
/tmp/dictionary 4953699
$
This example shows the dictionary file, along with its size. The information clearly
comes from the files collection, but we're getting ahead of ourselves. Let's take a
moment to step back and examine the output returned from the put command in this
example.
Using the _id Key
As you know, each document in MongoDB includes a unique identifier stored in the _id
key. Like MySQL's auto_increment field, the _id key is not of much direct interest, apart
from the fact that it allows you to pick out a specific file.
 
Search WWH ::




Custom Search