The present invention relates to a compound of Formula (I)-(IV) useful as β-lactamase inhibitor, a pharmaceutically acceptable salt, ester, solvate or stereoisomer thereof, wherein R1, R2, M and ring A have definitions as those in the specification. The present invention further relates to methods for preparing these compounds, pharmaceutical compositions comprising these compounds, and uses of these compounds. For example, the compounds of the present invention can be used as β-lactamase inhibitors, for treatment and/or prophylaxis of diseases caused by bacterial infections, solving drug-resistance problems caused by β-lactamases, especially bacterial drug-resistant diseases caused by type B metallo-β-lactamases.