Documentation
¶
Overview ¶
package mongo
package mongo
package mongo
package mongo
package mongo
package mongo
package mongo
package mongo
package mongo
package mongo
package mongo
package mongo
package mongo
package mongo
package mongo
package mongo
Index ¶
- Constants
- Variables
- func ObjectID2String(v ObjectID) string
- func ObjectIDIsZero[T objectIDType](id T) bool
- func SimpleAggregate()
- func SimpleBulkWrite()
- func SimpleCount()
- func SimpleCreateIndex()
- func SimpleDistinct()
- func SimpleFindDocs()
- func SimpleFindDocs2()
- func SimpleFindOne()
- func SimpleFindOneAndDelete()
- func SimpleFindOneAndReplace()
- func SimpleFindOneAndUpdate()
- func SimpleInsertDoc()
- func SimpleInsertDocs()
- func SimpleMixQ()
- func SimpleMongoNotQ()
- func SimpleMongoOrmQueryInsertOne()
- func SimpleMongoQ()
- func SimpleNewMongoQuery()
- func SimpleNewMongoQuery2()
- func SimpleNewMongoQuery3()
- func SimpleOrm()
- func SimpleProjection()
- func SimpleRef()
- func SimpleUpdateMany()
- func SimpleUpdateOne()
- func Struct2Map(raw interface{}, excludeKey ...string) map[string]interface{}
- func TransSession(cli *Client, fn func(sessionCtx SessionContext) error) error
- type BasicFindOptions
- type BasicUpdateOptions
- type BulkWriteModel
- func (bwm *BulkWriteModel) AddDeleteManyModel(filter *Query) *BulkWriteModel
- func (bwm *BulkWriteModel) AddDeleteOneModel(filter *Query) *BulkWriteModel
- func (bwm *BulkWriteModel) AddInsertOneModel(doc interface{}) *BulkWriteModel
- func (bwm *BulkWriteModel) AddNewReplaceOneModel(filter *Query, replaceDoc map[string]interface{}, upsert bool) *BulkWriteModel
- func (bwm *BulkWriteModel) AddUpdateManyCustomModel(filter *Query, update updateType, upDoc map[string]interface{}, upsert bool) *BulkWriteModel
- func (bwm *BulkWriteModel) AddUpdateManyModel(filter *Query, upDoc map[string]interface{}, upsert bool) *BulkWriteModel
- func (bwm *BulkWriteModel) AddUpdateOneCustomModel(filter *Query, update updateType, upDoc map[string]interface{}, upsert bool) *BulkWriteModel
- func (bwm *BulkWriteModel) AddUpdateOneModel(filter *Query, upDoc map[string]interface{}, upsert bool) *BulkWriteModel
- func (bwm *BulkWriteModel) Empty() bool
- func (bwm *BulkWriteModel) SetOrdered(ordered bool) *BulkWriteModel
- type BulkWriteResult
- type Client
- type ClientOptions
- type Collection
- func (c *Collection) Aggregate(ctx context.Context, results interface{}, serverMaxTime *time.Duration, ...) error
- func (c *Collection) BulkWrite(ctx context.Context, bwm *BulkWriteModel) (*BulkWriteResult, error)
- func (c *Collection) Count(ctx context.Context, filter *Query, opts *CountOptions) (int64, error)
- func (c *Collection) CreateManyIndex(ctx context.Context, indexList []ManyIndex) error
- func (c *Collection) CreateOneIndex(ctx context.Context, indexName string, keys []Index, indexUnique bool) error
- func (c *Collection) DeleteMany(ctx context.Context, filter *Query) (*DeleteResult, error)
- func (c *Collection) DeleteOne(ctx context.Context, filter *Query) (*DeleteResult, error)
- func (c *Collection) Distinct(ctx context.Context, fieldName string, filter *Query, ...) ([]interface{}, error)
- func (c *Collection) FindDocs(ctx context.Context, filter *Query, results interface{}, opts *FindOptions) error
- func (c *Collection) FindOne(ctx context.Context, filter *Query, result interface{}, opts *FindOneOptions) error
- func (c *Collection) FindOneAndDelete(ctx context.Context, filter *Query, delDoc interface{}, opts *FindOneAndDelete) error
- func (c *Collection) FindOneAndReplace(ctx context.Context, filter *Query, newDoc map[string]interface{}, ...) error
- func (c *Collection) FindOneAndUpdate(ctx context.Context, filter *Query, upDoc map[string]interface{}, ...) error
- func (c *Collection) FindOneAndUpdateCustom(ctx context.Context, filter *Query, customDoc map[string]interface{}, ...) error
- func (c *Collection) InsertDoc(ctx context.Context, doc map[string]interface{}) (string, error)
- func (c *Collection) InsertDocs(ctx context.Context, docs []interface{}, ordered bool) ([]string, error)
- func (c *Collection) ReplaceOne(ctx context.Context, filter *Query, replaceDoc map[string]interface{}, ...) (*UpdateResult, error)
- func (c *Collection) UpdateMany(ctx context.Context, filter *Query, upDoc map[string]interface{}, opts *Update) (*UpdateResult, error)
- func (c *Collection) UpdateManyCustom(ctx context.Context, filter *Query, update updateType, ...) (*UpdateResult, error)
- func (c *Collection) UpdateOne(ctx context.Context, filter *Query, upDoc map[string]interface{}, opts *Update) (*UpdateResult, error)
- func (c *Collection) UpdateOneCustom(ctx context.Context, filter *Query, update updateType, ...) (*UpdateResult, error)
- type Conf
- type CountOptions
- type Database
- type DeleteResult
- type FindOneAndDelete
- type FindOneAndReplace
- type FindOneAndUpdate
- type FindOneOptions
- type FindOptions
- type Foreign
- type ForeignList
- type Index
- type Limit
- type ManyIndex
- type ORM
- func (orm *ORM) BulkWrite(bwm *BulkWriteModel) (*BulkWriteResult, error)
- func (orm *ORM) ClearCache() *ORM
- func (orm *ORM) Client() *Client
- func (orm *ORM) Collection() *Collection
- func (orm *ORM) Cond() *Query
- func (orm *ORM) Count(clearCache bool) (int64, error)
- func (orm *ORM) Database() *Database
- func (orm *ORM) DeleteMany() (*DeleteResult, error)
- func (orm *ORM) DeleteOne() (*DeleteResult, error)
- func (orm *ORM) Distinct(b bool) *ORM
- func (orm *ORM) InsertMany(data []interface{}, ordered bool) ([]string, error)
- func (orm *ORM) InsertOne(data interface{}) (string, error)
- func (orm *ORM) KeepQuery(b bool) *ORM
- func (orm *ORM) Limit(size uint) *ORM
- func (orm *ORM) Order(cols ...string) *ORM
- func (orm *ORM) OverLimit(over, size uint) *ORM
- func (orm *ORM) Page(pageNo, pageSize uint) *ORM
- func (orm *ORM) PageData(target interface{}, pageNo, pageSize uint) (*Paging, error)
- func (orm *ORM) Projection(col string, value interface{}) *ORM
- func (orm *ORM) Projections(where Where) *ORM
- func (orm *ORM) Query(pair ...interface{}) *ORM
- func (orm *ORM) ReplaceOne(data map[string]interface{}, upsert bool) (*UpdateResult, error)
- func (orm *ORM) Select(cols ...string) *ORM
- func (orm *ORM) ToData(target interface{}) (err error)
- func (orm *ORM) ToJSON() string
- func (orm *ORM) UpdateMany(data map[string]interface{}, upsert bool) (*UpdateResult, error)
- func (orm *ORM) UpdateManyCustom(update updateType, data map[string]interface{}, upsert bool) (*UpdateResult, error)
- func (orm *ORM) UpdateOne(data map[string]interface{}, upsert bool) (*UpdateResult, error)
- func (orm *ORM) UpdateOneCustom(update updateType, data map[string]interface{}, upsert bool) (*UpdateResult, error)
- func (orm *ORM) Where(col string, value interface{}) *ORM
- func (orm *ORM) Wheres(where Where) *ORM
- type ObjectID
- type Order
- type Paging
- type Projection
- type Query
- func (q *Query) And(filter ...*Query) *Query
- func (q *Query) Cond() map[string]interface{}
- func (q *Query) Empty() bool
- func (q *Query) JSON() string
- func (q *Query) Nor(filter ...*Query) *Query
- func (q *Query) Or(filter ...*Query) *Query
- func (q *Query) SetRawCond(cond map[string]interface{}) *Query
- type RefWhere
- type Reference
- type Replace
- type Select
- type SessionContext
- type Tb1
- type Tb2
- type Tb3
- type Update
- type UpdateResult
- type Where
Constants ¶
const ( IndexTypeAscending = 1 IndexTypeDescending = -1 IndexTypeHashed = "hashed" IndexTypeText = "text" IndexTypeGeo2dSphere = "2dsphere" IndexTypeGeo2d = "2d" IndexTypeGeoHaystack = "geoHaystack" )
所有索引类型
const ( UpdateSet = updateType("$set") UpdateUnset = updateType("$unset") UpdateInc = updateType("$inc") UpdatePush = updateType("$push") UpdatePull = updateType("$pull") UpdatePop = updateType("$pop") )
更新类型名称
Variables ¶
var ( //ErrTargetNotSettable means the second param of Bind is not settable ErrTargetNotSettable = errors.New("[scanner]: target is not settable! a pointer is required") )
Functions ¶
func ObjectIDIsZero ¶
func ObjectIDIsZero[T objectIDType](id T) bool
func SimpleAggregate ¶
func SimpleAggregate()
func SimpleBulkWrite ¶
func SimpleBulkWrite()
func SimpleCount ¶
func SimpleCount()
func SimpleCreateIndex ¶
func SimpleCreateIndex()
func SimpleDistinct ¶
func SimpleDistinct()
func SimpleFindDocs ¶
func SimpleFindDocs()
func SimpleFindDocs2 ¶
func SimpleFindDocs2()
func SimpleFindOne ¶
func SimpleFindOne()
func SimpleFindOneAndDelete ¶
func SimpleFindOneAndDelete()
func SimpleFindOneAndReplace ¶
func SimpleFindOneAndReplace()
func SimpleFindOneAndUpdate ¶
func SimpleFindOneAndUpdate()
func SimpleInsertDoc ¶
func SimpleInsertDoc()
func SimpleInsertDocs ¶
func SimpleInsertDocs()
func SimpleMixQ ¶
func SimpleMixQ()
func SimpleMongoNotQ ¶
func SimpleMongoNotQ()
func SimpleMongoOrmQueryInsertOne ¶
func SimpleMongoOrmQueryInsertOne()
func SimpleMongoQ ¶
func SimpleMongoQ()
func SimpleNewMongoQuery ¶
func SimpleNewMongoQuery()
func SimpleNewMongoQuery2 ¶
func SimpleNewMongoQuery2()
func SimpleNewMongoQuery3 ¶
func SimpleNewMongoQuery3()
func SimpleProjection ¶
func SimpleProjection()
func SimpleUpdateMany ¶
func SimpleUpdateMany()
func SimpleUpdateOne ¶
func SimpleUpdateOne()
func Struct2Map ¶
func TransSession ¶
func TransSession(cli *Client, fn func(sessionCtx SessionContext) error) error
Types ¶
type BasicFindOptions ¶
type BasicFindOptions struct {
// contains filtered or unexported fields
}
func (*BasicFindOptions) Projection ¶
func (op *BasicFindOptions) Projection(projectionMap map[string]interface{}) *BasicFindOptions
func (*BasicFindOptions) Select ¶
func (op *BasicFindOptions) Select(cols []string) *BasicFindOptions
Select 设置需要展示或隐藏的字段 如:["key1", "-key2"],显示key1,隐藏key2
func (*BasicFindOptions) Sort ¶
func (op *BasicFindOptions) Sort(cols []string) *BasicFindOptions
Sort 设置排序字段 如:["key1", "-key2"],key1 升序,key2 降序
type BasicUpdateOptions ¶
type BasicUpdateOptions struct {
// contains filtered or unexported fields
}
func (*BasicUpdateOptions) Upsert ¶
func (op *BasicUpdateOptions) Upsert(b bool) *BasicUpdateOptions
type BulkWriteModel ¶
type BulkWriteModel struct {
// contains filtered or unexported fields
}
BulkWriteModel 批量写入模型
func (*BulkWriteModel) AddDeleteManyModel ¶
func (bwm *BulkWriteModel) AddDeleteManyModel(filter *Query) *BulkWriteModel
func (*BulkWriteModel) AddDeleteOneModel ¶
func (bwm *BulkWriteModel) AddDeleteOneModel(filter *Query) *BulkWriteModel
func (*BulkWriteModel) AddInsertOneModel ¶
func (bwm *BulkWriteModel) AddInsertOneModel(doc interface{}) *BulkWriteModel
func (*BulkWriteModel) AddNewReplaceOneModel ¶
func (bwm *BulkWriteModel) AddNewReplaceOneModel(filter *Query, replaceDoc map[string]interface{}, upsert bool) *BulkWriteModel
func (*BulkWriteModel) AddUpdateManyCustomModel ¶
func (bwm *BulkWriteModel) AddUpdateManyCustomModel(filter *Query, update updateType, upDoc map[string]interface{}, upsert bool) *BulkWriteModel
func (*BulkWriteModel) AddUpdateManyModel ¶
func (bwm *BulkWriteModel) AddUpdateManyModel(filter *Query, upDoc map[string]interface{}, upsert bool) *BulkWriteModel
func (*BulkWriteModel) AddUpdateOneCustomModel ¶
func (bwm *BulkWriteModel) AddUpdateOneCustomModel(filter *Query, update updateType, upDoc map[string]interface{}, upsert bool) *BulkWriteModel
AddUpdateOneCustomModel 自定义类型包含:
func (*BulkWriteModel) AddUpdateOneModel ¶
func (bwm *BulkWriteModel) AddUpdateOneModel(filter *Query, upDoc map[string]interface{}, upsert bool) *BulkWriteModel
func (*BulkWriteModel) Empty ¶
func (bwm *BulkWriteModel) Empty() bool
func (*BulkWriteModel) SetOrdered ¶
func (bwm *BulkWriteModel) SetOrdered(ordered bool) *BulkWriteModel
type BulkWriteResult ¶
type BulkWriteResult struct { // The number of documents inserted. InsertedCount int64 // The number of documents matched by filters in update and replace operations. MatchedCount int64 // The number of documents modified by update and replace operations. ModifiedCount int64 // The number of documents deleted. DeletedCount int64 // The number of documents upserted by update and replace operations. UpsertedCount int64 // A map of operation index to the _id of each upserted document. UpsertedIDs map[int64]interface{} }
BulkWriteResult is the result type returned by a BulkWrite operation.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) NewSession ¶
func (c *Client) NewSession(fn func(sessionCtx SessionContext) error) error
NewSession 要求mongo 版本 4.0起 需要mongo副本集群
type Collection ¶
type Collection struct { *Database // contains filtered or unexported fields }
func (*Collection) BulkWrite ¶
func (c *Collection) BulkWrite(ctx context.Context, bwm *BulkWriteModel) (*BulkWriteResult, error)
func (*Collection) Count ¶
func (c *Collection) Count(ctx context.Context, filter *Query, opts *CountOptions) (int64, error)
func (*Collection) CreateManyIndex ¶
func (c *Collection) CreateManyIndex(ctx context.Context, indexList []ManyIndex) error
CreateManyIndex 创建索引
func (*Collection) CreateOneIndex ¶
func (c *Collection) CreateOneIndex(ctx context.Context, indexName string, keys []Index, indexUnique bool) error
CreateOneIndex 创建索引
func (*Collection) DeleteMany ¶
func (c *Collection) DeleteMany(ctx context.Context, filter *Query) (*DeleteResult, error)
func (*Collection) DeleteOne ¶
func (c *Collection) DeleteOne(ctx context.Context, filter *Query) (*DeleteResult, error)
func (*Collection) FindDocs ¶
func (c *Collection) FindDocs(ctx context.Context, filter *Query, results interface{}, opts *FindOptions) error
FindDocs filter 查询对象 results slice 结果返回,可以是map or struct opts 查询参数选择
func (*Collection) FindOne ¶
func (c *Collection) FindOne(ctx context.Context, filter *Query, result interface{}, opts *FindOneOptions) error
FindOne filter 查询对象 results 结果返回,可以是map or struct
func (*Collection) FindOneAndDelete ¶
func (c *Collection) FindOneAndDelete(ctx context.Context, filter *Query, delDoc interface{}, opts *FindOneAndDelete) error
func (*Collection) FindOneAndReplace ¶
func (c *Collection) FindOneAndReplace(ctx context.Context, filter *Query, newDoc map[string]interface{}, oldDoc interface{}, opts *FindOneAndReplace) error
func (*Collection) FindOneAndUpdate ¶
func (c *Collection) FindOneAndUpdate(ctx context.Context, filter *Query, upDoc map[string]interface{}, oldDoc interface{}, opts *FindOneAndUpdate) error
func (*Collection) FindOneAndUpdateCustom ¶
func (c *Collection) FindOneAndUpdateCustom(ctx context.Context, filter *Query, customDoc map[string]interface{}, oldDoc interface{}, opts *FindOneAndUpdate) error
func (*Collection) InsertDocs ¶
func (c *Collection) InsertDocs(ctx context.Context, docs []interface{}, ordered bool) ([]string, error)
InsertDocs 添加数据
func (*Collection) ReplaceOne ¶
func (c *Collection) ReplaceOne(ctx context.Context, filter *Query, replaceDoc map[string]interface{}, opts *Replace) (*UpdateResult, error)
func (*Collection) UpdateMany ¶
func (c *Collection) UpdateMany(ctx context.Context, filter *Query, upDoc map[string]interface{}, opts *Update) (*UpdateResult, error)
func (*Collection) UpdateManyCustom ¶
func (c *Collection) UpdateManyCustom(ctx context.Context, filter *Query, update updateType, updateDoc map[string]interface{}, opts *Update) (*UpdateResult, error)
func (*Collection) UpdateOne ¶
func (c *Collection) UpdateOne(ctx context.Context, filter *Query, upDoc map[string]interface{}, opts *Update) (*UpdateResult, error)
func (*Collection) UpdateOneCustom ¶
func (c *Collection) UpdateOneCustom(ctx context.Context, filter *Query, update updateType, updateDoc map[string]interface{}, opts *Update) (*UpdateResult, error)
type CountOptions ¶
type CountOptions struct {
// contains filtered or unexported fields
}
func NewCount ¶
func NewCount() *CountOptions
type Database ¶
type Database struct { *Client // contains filtered or unexported fields }
func (*Database) Collection ¶
func (db *Database) Collection(name string) *Collection
func (*Database) TryCollection ¶
func (db *Database) TryCollection(name string) (c *Collection, exist bool, err error)
type DeleteResult ¶
type DeleteResult struct {
DeletedCount int64 // The number of documents deleted.
}
type FindOneAndDelete ¶
type FindOneAndDelete struct {
BasicFindOptions
}
func NewFindOneAndDelete ¶
func NewFindOneAndDelete() *FindOneAndDelete
type FindOneAndReplace ¶
type FindOneAndReplace struct { BasicFindOptions BasicUpdateOptions }
func NewFindOneAndReplace ¶
func NewFindOneAndReplace() *FindOneAndReplace
type FindOneAndUpdate ¶
type FindOneAndUpdate struct { BasicFindOptions BasicUpdateOptions }
func NewFindOneAndUpdate ¶
func NewFindOneAndUpdate() *FindOneAndUpdate
type FindOneOptions ¶
type FindOneOptions struct { BasicFindOptions // contains filtered or unexported fields }
type FindOptions ¶
type FindOptions struct { FindOneOptions // contains filtered or unexported fields }
FindOptions 查询文档限制条件
func (*FindOptions) Page ¶
func (op *FindOptions) Page(no int64, size int64) *FindOptions
Page 设置分页数据
type Foreign ¶
type Foreign[T dataType] struct { Ref string `bson:"$ref" json:"ref"` ID ObjectID `bson:"$id" json:"id"` }
Foreign mongotool 外键 tag: `bson "test" json:"test" ref:"def"` ref values [def, all, match] def: 有交集即可;all:所有的外键均存在;match:所有的外键均存在,并且与条件完全一致
type ForeignList ¶
type ForeignList[T dataType] []*Foreign[T]
ForeignList mongotool 外键数组 tag: `bson "test" json:"test" ref:"def"` ref values [def, all, match] def: 有交集即可;all:所有的外键均存在;match:所有的外键均存在,并且与条件完全一致
func ToRefListData ¶
func ToRefListData[T dataType, DT refListType[T]](r *Reference, data DT) (ForeignList[T], error)
type ORM ¶
type ORM struct { Q *mongoOrmQ // contains filtered or unexported fields }
func NewORMByClient ¶
func NewORMByDB ¶
func (*ORM) BulkWrite ¶
func (orm *ORM) BulkWrite(bwm *BulkWriteModel) (*BulkWriteResult, error)
func (*ORM) ClearCache ¶
func (*ORM) Collection ¶
func (orm *ORM) Collection() *Collection
func (*ORM) DeleteMany ¶
func (orm *ORM) DeleteMany() (*DeleteResult, error)
func (*ORM) DeleteOne ¶
func (orm *ORM) DeleteOne() (*DeleteResult, error)
func (*ORM) InsertMany ¶
func (*ORM) Projection ¶
func (*ORM) Projections ¶
func (*ORM) ReplaceOne ¶
func (orm *ORM) ReplaceOne(data map[string]interface{}, upsert bool) (*UpdateResult, error)
func (*ORM) UpdateMany ¶
func (orm *ORM) UpdateMany(data map[string]interface{}, upsert bool) (*UpdateResult, error)
func (*ORM) UpdateManyCustom ¶
func (orm *ORM) UpdateManyCustom(update updateType, data map[string]interface{}, upsert bool) (*UpdateResult, error)
func (*ORM) UpdateOne ¶
func (orm *ORM) UpdateOne(data map[string]interface{}, upsert bool) (*UpdateResult, error)
func (*ORM) UpdateOneCustom ¶
func (orm *ORM) UpdateOneCustom(update updateType, data map[string]interface{}, upsert bool) (*UpdateResult, error)
type Projection ¶
type Projection = map[string]interface{}
type Query ¶
type Query struct {
// contains filtered or unexported fields
}
Query = : "key": "val" or "key__eq": "val" < : "key__lt": 1 <= : "key__lte": 1 > : "key__gt": 1 >= : "key__gte": 1 != : "key__ne": 1 in : "key__in": [1] all : "key__all": [1, 2, 3] not in : "key__nin": [1] size : "arr__size": 1 exists : "key__exists": true mod : "key__mod": [10, 1], 基数,余数 elemMatch : "key__match": MongoQuery like :
"key__istartswith": "123" "key__startswith": "123" "key__iendswith": "123" "key__endswith": "123" "key__icontains": "123" "key__contains": "123"
geo within query 2dsphere
key__geo_within_polygon: [][]float64 or [][][]float64 闭合的多边形 key__geo_within_multi_polygon: [][][]float64 or [][][][]float64 多个闭合的多边形 key__geo_within_center_sphere: []float64, 长度必须是3,分辨为 lng, lat, radius(米)
geo intersects query 2dsphere
key__geo_intersects_polygon: [][]float64 or [][][]float64 闭合的多边形
geo near query 2dsphere
key__near: []float64 坐标点 or map[string]interface{}{ "point": []float64 坐标点, "min": 最小距离,单位:米, "max": 最大距离,单位:米 } key__near_sphere: []float64 坐标点 or map[string]interface{}{ "point": []float64 坐标点, "min": 最小距离,单位:米, "max": 最大距离,单位:米 }
geo within query 2d
key__geo_within_2d_box: [][]float64, bottom left, top right key__geo_within_2d_polygon: [][]float64 非闭合的多边形 key__geo_within_2d_center: []float64, 长度必须是3,分辨为 lng, lat, radius(米)
func MixQ ¶
MixQ ~: 结果取反,其中:$and、$or、$nor不适应 $and、$or、$nor: values type must be map[string]interface{} or []*MongoQuery or []interface or []map[string]interface{}
func (*Query) SetRawCond ¶
SetRawCond cond default nil means is not HQL and cond is not nil means use MongoQuery cond nil close raw query
type Reference ¶
type Reference struct {
// contains filtered or unexported fields
}
Reference 表定义
func NewReference ¶
func NewReference() *Reference
func (*Reference) AddTableDef ¶
type Replace ¶
type Replace struct {
BasicUpdateOptions
}
func NewReplace ¶
func NewReplace() *Replace
type SessionContext ¶
type SessionContext = mongo.SessionContext
type UpdateResult ¶
type UpdateResult struct { MatchedCount int64 // The number of documents matched by the filter. ModifiedCount int64 // The number of documents modified by the operation. UpsertedCount int64 // The number of documents upserted by the operation. UpsertedID interface{} // The _id field of the upserted document, or nil if no upsert was done. }