You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

deleteoptions.go 1.1 kB

5 years ago
123456789101112131415161718192021222324252627282930313233343536373839
  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. package options
  7. // DeleteOptions represents all possible options to the DeleteOne() and DeleteMany() functions.
  8. type DeleteOptions struct {
  9. Collation *Collation // Specifies a collation
  10. }
  11. // Delete returns a pointer to a new DeleteOptions
  12. func Delete() *DeleteOptions {
  13. return &DeleteOptions{}
  14. }
  15. // SetCollation specifies a collation
  16. // Valid for servers >= 3.4.
  17. func (do *DeleteOptions) SetCollation(c *Collation) *DeleteOptions {
  18. do.Collation = c
  19. return do
  20. }
  21. // MergeDeleteOptions combines the argued DeleteOptions into a single DeleteOptions in a last-one-wins fashion
  22. func MergeDeleteOptions(opts ...*DeleteOptions) *DeleteOptions {
  23. dOpts := Delete()
  24. for _, do := range opts {
  25. if do == nil {
  26. continue
  27. }
  28. if do.Collation != nil {
  29. dOpts.Collation = do.Collation
  30. }
  31. }
  32. return dOpts
  33. }