Quiz

  1. So is the parameter for .aggregate() a function? Could you please go through the Computing the Average in the Database example please?

    No, it's an array of documents, one document for each stage of the pipeline. Yes, we'll go through that example, twice.

  2. When do we need to put the attribute name in quotes? Name is not in quotes here:
    {$set: {name: ""Lord Voldemort"", back: true, nose: false}} 
    

    But addr.city is:

    {$set: {""addr.city"": ""Little Whinging"", 
            ""addr.county"": ""Surry""}}"
    

    Great question. We have dots in the second example because city and county are keys/properties within the address document. So, there's layers of structure there.

    We have to use quotation marks when there are odd characters, such as a dot, in the name of a property/key.

    There are two kinds of documents here. The query document and the database document. The database document is the one with extra layers. The query document is intended to match, and so we end up with dots.

  3. Can we expand more on the aggregation pipeline? Aggregation Pipelines - when should we know if it seems reasonable to do or if it's easier to use ordinary JavaScript? I'd definitely like to review aggregation and its implementation.

    All good questions. The aggregation pipeline is powerful but complicated. In this class, you should try to do computations in the database whenever possible. If it's not obvious, consult with me and we can try to figure it out together. If we can't, we'll compute in JavaScript.

  4. I did not quite understand the $set operator and would love it if we went over it in class.

    Sure. Here's some documentation on $set.

  5. I was wondering if the following in the reading was a typo: 'await wmdb.insertMany(newStaff, options);'? Don't we need to specify the collection?

    Wow! You are right! Thanks so much for noticing that!

  6. Composite keys and tricks on the intuition of coming up with them.

    Good. Let's discuss many-to-many mappings?

  7. I think I'm at the point where I need to practice what we're learning to figure out what the confusing parts are.

    Yes, that makes sense.

  8. I think all is clear! / no specific questions!

    Glad to hear it!