blob: 919d6b8ae79a03834306bcf920380b10eaeb2166 [file] [log] [blame]
Don Newton379ae252019-04-01 12:17:06 -04001// 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
7package options
8
9// DeleteOptions represents all possible options to the deleteOne() and deleteMany() functions
10type DeleteOptions struct {
11 Collation *Collation // Specifies a collation
12}
13
14// Delete returns a pointer to a new DeleteOptions
15func Delete() *DeleteOptions {
16 return &DeleteOptions{}
17}
18
19// SetCollation specifies a collation
20// Valid for servers >= 3.4.
21func (do *DeleteOptions) SetCollation(c *Collation) *DeleteOptions {
22 do.Collation = c
23 return do
24}
25
26// MergeDeleteOptions combines the argued DeleteOptions into a single DeleteOptions in a last-one-wins fashion
27func MergeDeleteOptions(opts ...*DeleteOptions) *DeleteOptions {
28 dOpts := Delete()
29 for _, do := range opts {
30 if do == nil {
31 continue
32 }
33 if do.Collation != nil {
34 dOpts.Collation = do.Collation
35 }
36 }
37
38 return dOpts
39}