-
Notifications
You must be signed in to change notification settings - Fork 892
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GODRIVER-2413 Add encryptedFields to Collection.Drop (#1446)
Co-authored-by: Kevin Albertson <kevin.albertson@mongodb.com> Co-authored-by: Kevin Albertson <kevin.albertson@10gen.com>
- Loading branch information
1 parent
9fd0424
commit ea38d1c
Showing
6 changed files
with
131 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright (C) MongoDB, Inc. 2017-present. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
// not use this file except in compliance with the License. You may obtain | ||
// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
package options | ||
|
||
// DropCollectionOptions represents options that can be used to configure a Drop operation. | ||
type DropCollectionOptions struct { | ||
// EncryptedFields configures encrypted fields for encrypted collections. | ||
// | ||
// This option is only valid for MongoDB versions >= 6.0 | ||
EncryptedFields interface{} | ||
} | ||
|
||
// DropCollection creates a new DropCollectionOptions instance. | ||
func DropCollection() *DropCollectionOptions { | ||
return &DropCollectionOptions{} | ||
} | ||
|
||
// SetEncryptedFields sets the encrypted fields for encrypted collections. | ||
func (d *DropCollectionOptions) SetEncryptedFields(encryptedFields interface{}) *DropCollectionOptions { | ||
d.EncryptedFields = encryptedFields | ||
return d | ||
} | ||
|
||
// MergeDropCollectionOptions combines the given DropCollectionOptions instances into a single | ||
// DropCollectionOptions in a last-one-wins fashion. | ||
func MergeDropCollectionOptions(opts ...*DropCollectionOptions) *DropCollectionOptions { | ||
dc := DropCollection() | ||
|
||
for _, opt := range opts { | ||
if opt == nil { | ||
continue | ||
} | ||
|
||
if opt.EncryptedFields != nil { | ||
dc.EncryptedFields = opt.EncryptedFields | ||
} | ||
} | ||
|
||
return dc | ||
} |