Upgrade dependent version: go.mongodb.org/mongo-driver (#5320)
Upgrade dependent version: go.mongodb.org/mongo-driver v1.3.2 -> v1.10.4 Signed-off-by: hongzhouzi <hongzhouzi@kubesphere.io> Signed-off-by: hongzhouzi <hongzhouzi@kubesphere.io>
This commit is contained in:
51
vendor/go.mongodb.org/mongo-driver/bson/primitive/primitive.go
generated
vendored
51
vendor/go.mongodb.org/mongo-driver/bson/primitive/primitive.go
generated
vendored
@@ -4,7 +4,7 @@
|
||||
// not use this file except in compliance with the License. You may obtain
|
||||
// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
// Package primitive contains types similar to Go primitives for BSON types can do not have direct
|
||||
// Package primitive contains types similar to Go primitives for BSON types that do not have direct
|
||||
// Go primitive representations.
|
||||
package primitive // import "go.mongodb.org/mongo-driver/bson/primitive"
|
||||
|
||||
@@ -21,7 +21,7 @@ type Binary struct {
|
||||
Data []byte
|
||||
}
|
||||
|
||||
// Equal compares bp to bp2 and returns true is the are equal.
|
||||
// Equal compares bp to bp2 and returns true if they are equal.
|
||||
func (bp Binary) Equal(bp2 Binary) bool {
|
||||
if bp.Subtype != bp2.Subtype {
|
||||
return false
|
||||
@@ -29,7 +29,7 @@ func (bp Binary) Equal(bp2 Binary) bool {
|
||||
return bytes.Equal(bp.Data, bp2.Data)
|
||||
}
|
||||
|
||||
// IsZero returns if bp is the empty Binary
|
||||
// IsZero returns if bp is the empty Binary.
|
||||
func (bp Binary) IsZero() bool {
|
||||
return bp.Subtype == 0 && len(bp.Data) == 0
|
||||
}
|
||||
@@ -40,11 +40,32 @@ type Undefined struct{}
|
||||
// DateTime represents the BSON datetime value.
|
||||
type DateTime int64
|
||||
|
||||
// MarshalJSON marshal to time type
|
||||
var _ json.Marshaler = DateTime(0)
|
||||
var _ json.Unmarshaler = (*DateTime)(nil)
|
||||
|
||||
// MarshalJSON marshal to time type.
|
||||
func (d DateTime) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(d.Time())
|
||||
}
|
||||
|
||||
// UnmarshalJSON creates a primitive.DateTime from a JSON string.
|
||||
func (d *DateTime) UnmarshalJSON(data []byte) error {
|
||||
// Ignore "null" to keep parity with the time.Time type and the standard library. Decoding "null" into a non-pointer
|
||||
// DateTime field will leave the field unchanged. For pointer values, the encoding/json will set the pointer to nil
|
||||
// and will not defer to the UnmarshalJSON hook.
|
||||
if string(data) == "null" {
|
||||
return nil
|
||||
}
|
||||
|
||||
var tempTime time.Time
|
||||
if err := json.Unmarshal(data, &tempTime); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
*d = NewDateTimeFromTime(tempTime)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Time returns the date as a time type.
|
||||
func (d DateTime) Time() time.Time {
|
||||
return time.Unix(int64(d)/1000, int64(d)%1000*1000000)
|
||||
@@ -52,7 +73,7 @@ func (d DateTime) Time() time.Time {
|
||||
|
||||
// NewDateTimeFromTime creates a new DateTime from a Time.
|
||||
func NewDateTimeFromTime(t time.Time) DateTime {
|
||||
return DateTime(t.UnixNano() / 1000000)
|
||||
return DateTime(t.Unix()*1e3 + int64(t.Nanosecond())/1e6)
|
||||
}
|
||||
|
||||
// Null represents the BSON null value.
|
||||
@@ -68,12 +89,12 @@ func (rp Regex) String() string {
|
||||
return fmt.Sprintf(`{"pattern": "%s", "options": "%s"}`, rp.Pattern, rp.Options)
|
||||
}
|
||||
|
||||
// Equal compares rp to rp2 and returns true is the are equal.
|
||||
// Equal compares rp to rp2 and returns true if they are equal.
|
||||
func (rp Regex) Equal(rp2 Regex) bool {
|
||||
return rp.Pattern == rp2.Pattern && rp.Options == rp2.Options
|
||||
}
|
||||
|
||||
// IsZero returns if rp is the empty Regex
|
||||
// IsZero returns if rp is the empty Regex.
|
||||
func (rp Regex) IsZero() bool {
|
||||
return rp.Pattern == "" && rp.Options == ""
|
||||
}
|
||||
@@ -88,12 +109,12 @@ func (d DBPointer) String() string {
|
||||
return fmt.Sprintf(`{"db": "%s", "pointer": "%s"}`, d.DB, d.Pointer)
|
||||
}
|
||||
|
||||
// Equal compares d to d2 and returns true is the are equal.
|
||||
// Equal compares d to d2 and returns true if they are equal.
|
||||
func (d DBPointer) Equal(d2 DBPointer) bool {
|
||||
return d.DB == d2.DB && bytes.Equal(d.Pointer[:], d2.Pointer[:])
|
||||
return d == d2
|
||||
}
|
||||
|
||||
// IsZero returns if d is the empty DBPointer
|
||||
// IsZero returns if d is the empty DBPointer.
|
||||
func (d DBPointer) IsZero() bool {
|
||||
return d.DB == "" && d.Pointer.IsZero()
|
||||
}
|
||||
@@ -120,12 +141,12 @@ type Timestamp struct {
|
||||
I uint32
|
||||
}
|
||||
|
||||
// Equal compares tp to tp2 and returns true is the are equal.
|
||||
// Equal compares tp to tp2 and returns true if they are equal.
|
||||
func (tp Timestamp) Equal(tp2 Timestamp) bool {
|
||||
return tp.T == tp2.T && tp.I == tp2.I
|
||||
}
|
||||
|
||||
// IsZero returns if tp is the zero Timestamp
|
||||
// IsZero returns if tp is the zero Timestamp.
|
||||
func (tp Timestamp) IsZero() bool {
|
||||
return tp.T == 0 && tp.I == 0
|
||||
}
|
||||
@@ -161,7 +182,7 @@ type MaxKey struct{}
|
||||
//
|
||||
// Example usage:
|
||||
//
|
||||
// bson.D{{"foo", "bar"}, {"hello", "world"}, {"pi", 3.14159}}
|
||||
// bson.D{{"foo", "bar"}, {"hello", "world"}, {"pi", 3.14159}}
|
||||
type D []E
|
||||
|
||||
// Map creates a map from the elements of the D.
|
||||
@@ -185,12 +206,12 @@ type E struct {
|
||||
//
|
||||
// Example usage:
|
||||
//
|
||||
// bson.M{"foo": "bar", "hello": "world", "pi": 3.14159}.
|
||||
// bson.M{"foo": "bar", "hello": "world", "pi": 3.14159}
|
||||
type M map[string]interface{}
|
||||
|
||||
// An A is an ordered representation of a BSON array.
|
||||
//
|
||||
// Example usage:
|
||||
//
|
||||
// bson.A{"bar", "world", 3.14159, bson.D{{"qux", 12345}}}
|
||||
// bson.A{"bar", "world", 3.14159, bson.D{{"qux", 12345}}}
|
||||
type A []interface{}
|
||||
|
||||
Reference in New Issue
Block a user