async function query4(artworkID) {
    //assume parameter artworkID is 14
    let db;
    artworkID = 14;
    const client = new MongoClient(uri, { useUnifiedTopology: true });
    try {
        await client.connect();
        db = client.db("Arts");
        const artworkCollection = db.collection("artworks");
        const query = { artworkID: Number(artworkID) };
        //get the statusType before update
        const res = await artworkCollection.findOne(query);
        console.log(
            "query 4: statusType of the artwork whose artworkID is 14 before update:",
            res.status.statusType
        );
        const ans = await artworkCollection.updateOne(
            {
                artworkID: Number(artworkID),
            },
            {
                $set: {
                    status: { statusType: "nullStatus" },
                },
            }
        );
        //get the statusType after update
        const res2 = await artworkCollection.findOne(query);
        console.log(
            "query 4: statusType of the artwork whose artworkID is 14 after update:",
            res2.status.statusType
        );
    } finally {
        client.close();
    }
}
// assume we want to update the status.statusType of the record whose artworkID is 14
assume we want to update the status.statusType of the record whose artworkID is 14
assume we want to update the status . statusType of the record whose artworkID is 14
async function query4(artworkID) {
    let db;
    artworkID = 14;
    const client = new MongoClient(uri, { useUnifiedTopology: true });
    try {
        await client.connect();
        db = client.db("Arts");
        const artworkCollection = db.collection("artworks");
        const query = { artworkID: Number(artworkID) };
        const res = await artworkCollection.findOne(query);
        console.log(
            "query 4: statusType of the artwork whose artworkID is 14 before update:",
            res.status.statusType
        );
        const ans = await artworkCollection.updateOne(
            {
                artworkID: Number(artworkID),
            },
            {
                $set: {
                    status: { statusType: "nullStatus" },
                },
            }
        );
        const res2 = await artworkCollection.findOne(query);
        console.log(
            "query 4: statusType of the artwork whose artworkID is 14 after update:",
            res2.status.statusType
        );
    } finally {
        client.close();
    }
}
async function query4 ( artworkID ) { let db ; artworkID = 14 ; const client = new MongoClient ( uri , { useUnifiedTopology : true } ) ; try { await client . connect ( ) ; db = client . db ( "Arts" ) ; const artworkCollection = db . collection ( "artworks" ) ; const query = { artworkID : Number ( artworkID ) } ; const res = await artworkCollection . findOne ( query ) ; console . log ( "query 4: statusType of the artwork whose artworkID is 14 before update:" , res . status . statusType ) ; const ans = await artworkCollection . updateOne ( { artworkID : Number ( artworkID ) , } , { $set : { status : { statusType : "nullStatus" } , } , } ) ; const res2 = await artworkCollection . findOne ( query ) ; console . log ( "query 4: statusType of the artwork whose artworkID is 14 after update:" , res2 . status . statusType ) ; } finally { client . close ( ) ; } }
assume we want to update the status.statusType of the record whose artworkID is 14
assume we want to update the status . statusType of the record whose artworkID is 14
//assume parameter artworkID is 14 //get the statusType before update //get the statusType after update