Skip to content

Commit 53ecaa3

Browse files
author
Divjot Arora
authored
GODRIVER-1061 Remove references to RawArray and Array types in BSON docs (#248)
1 parent 9e8d14a commit 53ecaa3

File tree

3 files changed

+24
-54
lines changed

3 files changed

+24
-54
lines changed

bson/bson.go

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,39 +22,29 @@ type Zeroer interface {
2222
IsZero() bool
2323
}
2424

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.
25+
// D is an ordered representation of a BSON document. This type should be used when the order of the elements matters,
26+
// such as MongoDB command documents. If the order of the elements does not matter, an M should be used instead.
2827
//
2928
// Example usage:
3029
//
3130
// 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.
3531
type D = primitive.D
3632

3733
// E represents a BSON element for a D. It is usually used inside a D.
3834
type E = primitive.E
3935

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.
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.
4339
//
4440
// Example usage:
4541
//
4642
// 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.
5043
type M = primitive.M
5144

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.
45+
// An A is an ordered representation of a BSON array.
5546
//
5647
// Example usage:
5748
//
5849
// bson.A{"bar", "world", 3.14159, bson.D{{"qux", 12345}}}
59-
//
6050
type A = primitive.A

bson/bson_1_8.go

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,12 @@ type Zeroer interface {
2121
IsZero() bool
2222
}
2323

24-
// D represents a BSON Document. This type can be used to represent BSON in a concise and readable
25-
// manner. It should generally be used when serializing to BSON. For deserializing, the Raw or
26-
// Document types should be used.
24+
// D is an ordered representation of a BSON document. This type should be used when the order of the elements matters,
25+
// such as MongoDB command documents. If the order of the elements does not matter, an M should be used instead.
2726
//
2827
// Example usage:
2928
//
30-
// primitive.D{{"foo", "bar"}, {"hello", "world"}, {"pi", 3.14159}}
31-
//
32-
// This type should be used in situations where order matters, such as MongoDB commands. If the
33-
// order is not important, a map is more comfortable and concise.
29+
// bson.D{{"foo", "bar"}, {"hello", "world"}, {"pi", 3.14159}}
3430
type D []E
3531

3632
// Map creates a map from the elements of the D.
@@ -48,26 +44,20 @@ type E struct {
4844
Value interface{}
4945
}
5046

51-
// M is an unordered, concise representation of a BSON Document. It should generally be used to
52-
// serialize BSON when the order of the elements of a BSON document do not matter. If the element
53-
// order matters, use a D instead.
47+
// M is an unordered representation of a BSON document. This type should be used when the order of the elements does not
48+
// matter. This type is handled as a regular map[string]interface{} when encoding and decoding. Elements will be
49+
// serialized in an undefined, random order. If the order of the elements matters, a D should be used instead.
5450
//
5551
// Example usage:
5652
//
57-
// primitive.M{"foo": "bar", "hello": "world", "pi": 3.14159}
58-
//
59-
// This type is handled in the encoders as a regular map[string]interface{}. The elements will be
60-
// serialized in an undefined, random order, and the order will be different each time.
53+
// bson.M{"foo": "bar", "hello": "world", "pi": 3.14159}
6154
type M map[string]interface{}
6255

63-
// An A represents a BSON array. This type can be used to represent a BSON array in a concise and
64-
// readable manner. It should generally be used when serializing to BSON. For deserializing, the
65-
// RawArray or Array types should be used.
56+
// An A is an ordered representation of a BSON array.
6657
//
6758
// Example usage:
6859
//
69-
// primitive.A{"bar", "world", 3.14159, primitive.D{{"qux", 12345}}}
70-
//
60+
// bson.A{"bar", "world", 3.14159, bson.D{{"qux", 12345}}}
7161
type A []interface{}
7262

7363
func formatDouble(f float64) string {

bson/primitive/primitive.go

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -156,16 +156,12 @@ type MinKey struct{}
156156
// MaxKey represents the BSON maxkey value.
157157
type MaxKey struct{}
158158

159-
// D represents a BSON Document. This type can be used to represent BSON in a concise and readable
160-
// manner. It should generally be used when serializing to BSON. For deserializing, the Raw or
161-
// Document types should be used.
159+
// D is an ordered representation of a BSON document. This type should be used when the order of the elements matters,
160+
// such as MongoDB command documents. If the order of the elements does not matter, an M should be used instead.
162161
//
163162
// Example usage:
164163
//
165-
// primitive.D{{"foo", "bar"}, {"hello", "world"}, {"pi", 3.14159}}
166-
//
167-
// This type should be used in situations where order matters, such as MongoDB commands. If the
168-
// order is not important, a map is more comfortable and concise.
164+
// bson.D{{"foo", "bar"}, {"hello", "world"}, {"pi", 3.14159}}
169165
type D []E
170166

171167
// Map creates a map from the elements of the D.
@@ -183,24 +179,18 @@ type E struct {
183179
Value interface{}
184180
}
185181

186-
// M is an unordered, concise representation of a BSON Document. It should generally be used to
187-
// serialize BSON when the order of the elements of a BSON document do not matter. If the element
188-
// order matters, use a D instead.
182+
// M is an unordered representation of a BSON document. This type should be used when the order of the elements does not
183+
// matter. This type is handled as a regular map[string]interface{} when encoding and decoding. Elements will be
184+
// serialized in an undefined, random order. If the order of the elements matters, a D should be used instead.
189185
//
190186
// Example usage:
191187
//
192-
// primitive.M{"foo": "bar", "hello": "world", "pi": 3.14159}
193-
//
194-
// This type is handled in the encoders as a regular map[string]interface{}. The elements will be
195-
// serialized in an undefined, random order, and the order will be different each time.
188+
// bson.M{"foo": "bar", "hello": "world", "pi": 3.14159}.
196189
type M map[string]interface{}
197190

198-
// An A represents a BSON array. This type can be used to represent a BSON array in a concise and
199-
// readable manner. It should generally be used when serializing to BSON. For deserializing, the
200-
// RawArray or Array types should be used.
191+
// An A is an ordered representation of a BSON array.
201192
//
202193
// Example usage:
203194
//
204-
// primitive.A{"bar", "world", 3.14159, primitive.D{{"qux", 12345}}}
205-
//
195+
// bson.A{"bar", "world", 3.14159, bson.D{{"qux", 12345}}}
206196
type A []interface{}

0 commit comments

Comments
 (0)