本站源代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
2.2KB

  1. // Copyright (C) MongoDB, Inc. 2017-present.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License"); you may
  4. // not use this file except in compliance with the License. You may obtain
  5. // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
  6. //
  7. // Based on gopkg.in/mgo.v2/bson by Gustavo Niemeyer
  8. // See THIRD-PARTY-NOTICES for original license terms.
  9. // +build go1.9
  10. package bson // import "go.mongodb.org/mongo-driver/bson"
  11. import (
  12. "go.mongodb.org/mongo-driver/bson/primitive"
  13. )
  14. // Zeroer allows custom struct types to implement a report of zero
  15. // state. All struct types that don't implement Zeroer or where IsZero
  16. // returns false are considered to be not zero.
  17. type Zeroer interface {
  18. IsZero() bool
  19. }
  20. // D represents a BSON Document. This type can be used to represent BSON in a concise and readable
  21. // manner. It should generally be used when serializing to BSON. For deserializing, the Raw or
  22. // Document types should be used.
  23. //
  24. // Example usage:
  25. //
  26. // bson.D{{"foo", "bar"}, {"hello", "world"}, {"pi", 3.14159}}
  27. //
  28. // This type should be used in situations where order matters, such as MongoDB commands. If the
  29. // order is not important, a map is more comfortable and concise.
  30. type D = primitive.D
  31. // E represents a BSON element for a D. It is usually used inside a D.
  32. type E = primitive.E
  33. // M is an unordered, concise representation of a BSON Document. It should generally be used to
  34. // serialize BSON when the order of the elements of a BSON document do not matter. If the element
  35. // order matters, use a D instead.
  36. //
  37. // Example usage:
  38. //
  39. // bson.M{"foo": "bar", "hello": "world", "pi": 3.14159}
  40. //
  41. // This type is handled in the encoders as a regular map[string]interface{}. The elements will be
  42. // serialized in an undefined, random order, and the order will be different each time.
  43. type M = primitive.M
  44. // An A represents a BSON array. This type can be used to represent a BSON array in a concise and
  45. // readable manner. It should generally be used when serializing to BSON. For deserializing, the
  46. // RawArray or Array types should be used.
  47. //
  48. // Example usage:
  49. //
  50. // bson.A{"bar", "world", 3.14159, bson.D{{"qux", 12345}}}
  51. //
  52. type A = primitive.A
上海开阖软件有限公司 沪ICP备12045867号-1