Mongodb Pymongo using $set to create an array/list/collection
<p>I'm trying to use $set to create an array/list/collection (not sure which is proper terminology), and I'm not sure how to do it. For example:</p>

<p>I have a document inserted into my database that looks like this:</p>

<pre><code>"_id": (unique, auto-generated id)
"Grade": Sophomore
</code></pre>

<p>I want to insert a collection/list/array using update. So, basically I want this:</p>

<pre><code>"_id": (unique, auto-generated id)
"Grade": Sophomore
"Information"{
           "Class_Info": [
                        {"Class_Name": "Math"}
                         ]
</code></pre>

<p>What I've been doing so far is using .update and dot notation. So, what I was trying to do was use $set like this: </p>

<pre><code>collection.update({'_id': unique ID}, {'$set': {'Information.Class_Info.Class_Name': 'Math}})
</code></pre>

<p>However, what that is doing is making Class_Info a document and not a list/collection/array, so it's doing:</p>

<pre><code>"_id": (unique id)
"Grade": Sophomore
"Information"{
           "Class_Info": {
                        "Class_Name": "Math"
                         }
</code></pre>

<p>How do I specify that I want Class_Info to be a list? IF for some reason I absolutely cannot use $set to do this, it is very important that I can use dot notation because of the way the rest of my program works, so if I'm supposed to use something other than $set, can it have dot notation to specify where to insert the list? (I know $push is another option, but it doesn't use dot notation, so I can't really use it in my case).</p>

<p>Thanks!</p>