MongoDB Update If… Else… Statement


So I’m trying to run a MongoDB update operation that includes a few conditions but I’m unsure of the correct syntax to use.

For example,

if field name "status" equals "some value", then change the value to "some other value"

…then after that

if field name "files_uploaded" equals field name "files_uploaded_total" set field name "status" to value "done"

I thought this modifier might do it, but apparently not:

    var modifier = {
        // If status = submitted, then set to started.
        $cond: [{$eq:["$status","submitted"]}, "started"],
        // If all files have been uploaded, set status to done.
        $cond: [{$eq:["$files_uploaded", "$files_uploaded_total"]}, "done"]
    my_collection.update(id, modifier);


it is

status: { $eq: "submitted"}

and $cond is aggregation operator, not for update