check err is not found

This commit is contained in:
Sinh 2021-11-10 16:40:11 +07:00
parent a8ab24a96c
commit ff7ee4fc11
3 changed files with 13 additions and 2 deletions

12
error.go Normal file
View File

@ -0,0 +1,12 @@
package mongodb
import (
"errors"
"go.mongodb.org/mongo-driver/mongo"
)
// IsErrNotFound check err is not found document
func IsErrNotFound(err error) bool {
return errors.Is(err, mongo.ErrNoDocuments)
}

2
go.mod
View File

@ -5,5 +5,5 @@ go 1.16
require (
github.com/logrusorgru/aurora v2.0.3+incompatible
go.mongodb.org/mongo-driver v1.7.1
golang.org/x/text v0.3.7 // indirect
golang.org/x/text v0.3.7
)

1
go.sum
View File

@ -101,7 +101,6 @@ golang.org/x/sys v0.0.0-20190419153524-e8e3143a4f4a/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190531175056-4c3a928424d2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.5 h1:i6eZZ+zk0SOf0xgBpEpPD18qWcJda6q1sxt3S0kzyUQ=
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=