Update subdocument reference in collection by only id

i have mongodb compass with collection in it got subdocument ref to other collection i want to update ref subdocument to only id of, and remove the subdocument
cat{id, code}
proc{id, title, cat{id, code}
i want to get proc{id, title, catid} for document in proc.

Something like this?

    $set: {
      catid: "$cat.catid"
    $unset: "cat"
  multi: true

i have tested it but not work and gives {
acknowledged: true,
insertedId: null,
matchedCount: 0,
modifiedCount: 0,
upsertedCount: 0
} why ? “$cat.catid” is as object in mongodb compass

I thought you wanted to replace the aub document with just the reference?

Put whats not working in mongo playground so we can take a look, just one document shoukd be ok with the update youre trying to do.

Or a screenshot of the document and update.

If the update is not matching anything in the filter to update then nothing will change, what filter did you apply when running the update?