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