This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export enum MongoErrorCode { | |
OK = 0, | |
InternalError = 1, | |
BadValue = 2, | |
OBSOLETE_DuplicateKey = 3, | |
NoSuchKey = 4, | |
GraphContainsCycle = 5, | |
HostUnreachable = 6,// Categories: NetworkError, RetriableError | |
HostNotFound = 7,// Categories: NetworkError, RetriableError | |
UnknownError = 8, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//equivalent of "select count (distinct fieldName) from someTable" | |
db.someCollection.aggregate([{ $group: { _id: "$fieldName"} },{ $group: { _id: 1, count: { $sum: 1 } } } ]) |