DropIndex 추가
This commit is contained in:
12
mongo.go
12
mongo.go
@ -124,6 +124,18 @@ func (mc MongoClient) Close() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (mc MongoClient) DropIndex(coll CollectionName, name string) error {
|
||||||
|
matchcoll := mc.Collection(coll)
|
||||||
|
_, err := matchcoll.Indexes().DropOne(context.Background(), name)
|
||||||
|
if commanderr, ok := err.(mongo.CommandError); ok {
|
||||||
|
if commanderr.Code == 27 {
|
||||||
|
// 인덱스가 없는 것이므로 그냥 성공
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
func (mc MongoClient) Watch(coll CollectionName, pipeline mongo.Pipeline, opts ...*options.ChangeStreamOptions) (*mongo.ChangeStream, error) {
|
func (mc MongoClient) Watch(coll CollectionName, pipeline mongo.Pipeline, opts ...*options.ChangeStreamOptions) (*mongo.ChangeStream, error) {
|
||||||
if len(opts) == 0 {
|
if len(opts) == 0 {
|
||||||
opts = []*options.ChangeStreamOptions{options.ChangeStream().SetFullDocument(options.UpdateLookup).SetMaxAwaitTime(0)}
|
opts = []*options.ChangeStreamOptions{options.ChangeStream().SetFullDocument(options.UpdateLookup).SetMaxAwaitTime(0)}
|
||||||
|
|||||||
Reference in New Issue
Block a user