How to get the amount of counties and zip codes there are in a State with the same State Code – MongoDB, Node.Js, Mongoose

I have a problem that I have been trying to work out and need some guidance. I have a Mongo Atlas database with US State information fields such as zip codes, city, county, county codes, state, state codes (ex. NY), longitude, latitude, number of zip codes, and number of counties.

My objective is to get the total number of zip codes and counties in a single State that has the same state code. Once I get the totals I want to update the field values num_of_counties and num_of_zips.

My thought is to get the sum of the lengths of both the zip codes and the counties. The setting the values to a variable which will be used in the $set field value.

Thank you in advance!

Zip Route

const express = require('express');
const router = express.Router();

const Zip = require('../models/Zip')

router.get('/', async (req, res) => {
    try {

        const zipCode = await Zip.find({ zips: req.id });

        console.log(zipCode);

        res.json(zipCode)
    } catch (err) {
        console.error(err.message);
        res.status(500).send('Server Error')
    }
});

router.get('/:zip', async (req, res) => {
    try {

        const zipCode = await Zip.find({ zip: req.params.zip }, {
            _id: 0,
            city: 1,
            county: 1,
            state: 1,
            state_code: 1
        });

        console.log(zipCode);

        res.json(zipCode)
    } catch (err) {
        console.error(err.message);
        res.status(500).send('Server Error')
    }
});


router.put('/', async (req, res) => {
    try {
        const zipVals = await Zip.aggregate([{ $group: { state_code: "state_code", zip: { $sum: "$zip" } } }])
        console.log(zipVals);
        const numOfCounties = await Zip.updateMany({}, { $set: { num_of_counties: 1 } })
        const numOfZipCodes = await Zip.updateMany({}, { $set: { num_of_zips: zipVals } })

        res.json([numOfCounties, numOfZipCodes])

    } catch (err) {
        console.error(err.message);
        res.status(500).send('Server Error')
    }
})


module.exports = router;

Model

const mongoose = require('mongoose');

const ZipSchema = mongoose.Schema({
    zip: {
        type: String,
    },
    city: {
        type: String,
    },
    state: {
        type: String,
    },
    state_code: {
        type: String,
    },
    county: {
        type: String,
    },
    county_code: {
        type: String,
    },
    latitude: {
        type: String,
    },
    longitude: {
        type: String,
    },
    num_of_counties: {
        type: Number,
    },
    num_of_zips: {
        type: Number,
    }

});

module.exports = mongoose.model('zip', ZipSchema)