How to query the number of records of Filter's duplicate data in mongodb of node

do you want to query the number of records in a collection that are not duplicated by deptId?

the instruction db.model.distinct on the mongodb command line ("deptId"). Length can be implemented, but it can"t be used in node. How do you use it in node?

Oct.27,2021

db.collection("model").aggregate([
    {'$group': {_id: "$deptId"}}
]).then((err, c) => {
...
});
The distinct method under

shell is obsolete and is not recommended. It is believed that this method will be removed in a later version. But distinct is essentially group , which is the same in SQL, so just replace it with group .

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1ea9fc8-47d73.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1ea9fc8-47d73.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?