Don Newton | 379ae25 | 2019-04-01 12:17:06 -0400 | [diff] [blame^] | 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 | |
| 10 | // +build go1.9 |
| 11 | |
| 12 | package bson |
| 13 | |
| 14 | import ( |
| 15 | "github.com/mongodb/mongo-go-driver/bson/primitive" |
| 16 | ) |
| 17 | |
| 18 | // Zeroer allows custom struct types to implement a report of zero |
| 19 | // state. All struct types that don't implement Zeroer or where IsZero |
| 20 | // returns false are considered to be not zero. |
| 21 | type Zeroer interface { |
| 22 | IsZero() bool |
| 23 | } |
| 24 | |
| 25 | // D represents a BSON Document. This type can be used to represent BSON in a concise and readable |
| 26 | // manner. It should generally be used when serializing to BSON. For deserializing, the Raw or |
| 27 | // Document types should be used. |
| 28 | // |
| 29 | // Example usage: |
| 30 | // |
| 31 | // bson.D{{"foo", "bar"}, {"hello", "world"}, {"pi", 3.14159}} |
| 32 | // |
| 33 | // This type should be used in situations where order matters, such as MongoDB commands. If the |
| 34 | // order is not important, a map is more comfortable and concise. |
| 35 | type D = primitive.D |
| 36 | |
| 37 | // E represents a BSON element for a D. It is usually used inside a D. |
| 38 | type E = primitive.E |
| 39 | |
| 40 | // M is an unordered, concise representation of a BSON Document. It should generally be used to |
| 41 | // serialize BSON when the order of the elements of a BSON document do not matter. If the element |
| 42 | // order matters, use a D instead. |
| 43 | // |
| 44 | // Example usage: |
| 45 | // |
| 46 | // bson.M{"foo": "bar", "hello": "world", "pi": 3.14159} |
| 47 | // |
| 48 | // This type is handled in the encoders as a regular map[string]interface{}. The elements will be |
| 49 | // serialized in an undefined, random order, and the order will be different each time. |
| 50 | type M = primitive.M |
| 51 | |
| 52 | // An A represents a BSON array. This type can be used to represent a BSON array in a concise and |
| 53 | // readable manner. It should generally be used when serializing to BSON. For deserializing, the |
| 54 | // RawArray or Array types should be used. |
| 55 | // |
| 56 | // Example usage: |
| 57 | // |
| 58 | // bson.A{"bar", "world", 3.14159, bson.D{{"qux", 12345}}} |
| 59 | // |
| 60 | type A = primitive.A |