Reputation: 12867
This page in the documentation says you can access a collection using c[name]
or c.name
, where c is a Collection, but what exactly does a sub-collection mean? I couldn't find any use of the term in the mongodb docs.
What I'm assuming, is that it gets the value of each document at key name
, wihtin the collection, and represents that as its own collection. Is this the case?
Upvotes: 2
Views: 808
Reputation: 312035
A subcollection is just a naming convention of using .
in a collection name as a way to organize your collection names.
So with the following code:
client = pymongo.MongoClient()
db = client['mydb']
coll = db['test']
subcoll = coll['subtest']
subcoll
is a collection with a name of test.subtest
. There's no defined relationship between test
and test.subtest
, it's just naming.
Upvotes: 5