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 package bson // import "go.mongodb.org/mongo-driver/bson"
11 12 import (
13 "go.mongodb.org/mongo-driver/bson/primitive"
14 )
15 16 // Zeroer allows custom struct types to implement a report of zero
17 // state. All struct types that don't implement Zeroer or where IsZero
18 // returns false are considered to be not zero.
19 type Zeroer interface {
20 IsZero() bool
21 }
22 23 // D is an ordered representation of a BSON document. This type should be used when the order of the elements matters,
24 // such as MongoDB command documents. If the order of the elements does not matter, an M should be used instead.
25 //
26 // A D should not be constructed with duplicate key names, as that can cause undefined server behavior.
27 //
28 // Example usage:
29 //
30 // bson.D{{"foo", "bar"}, {"hello", "world"}, {"pi", 3.14159}}
31 type D = primitive.D
32 33 // E represents a BSON element for a D. It is usually used inside a D.
34 type E = primitive.E
35 36 // M is an unordered representation of a BSON document. This type should be used when the order of the elements does not
37 // matter. This type is handled as a regular map[string]interface{} when encoding and decoding. Elements will be
38 // serialized in an undefined, random order. If the order of the elements matters, a D should be used instead.
39 //
40 // Example usage:
41 //
42 // bson.M{"foo": "bar", "hello": "world", "pi": 3.14159}
43 type M = primitive.M
44 45 // An A is an ordered representation of a BSON array.
46 //
47 // Example usage:
48 //
49 // bson.A{"bar", "world", 3.14159, bson.D{{"qux", 12345}}}
50 type A = primitive.A
51