FindOneAndUpdateOptions.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /* Copyright 2010-2017 MongoDB Inc.
  2. *
  3. * Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software
  10. * distributed under the License is distributed on an "AS IS" BASIS,
  11. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. * See the License for the specific language governing permissions and
  13. * limitations under the License.
  14. */
  15. using System;
  16. using System.Collections.Generic;
  17. using System.Linq;
  18. namespace MongoDB.Driver
  19. {
  20. /// <summary>
  21. /// Options for a findAndModify command to update an object.
  22. /// </summary>
  23. /// <typeparam name="TDocument">The type of the document.</typeparam>
  24. /// <typeparam name="TProjection">The type of the projection (same as TDocument if there is no projection).</typeparam>
  25. public class FindOneAndUpdateOptions<TDocument, TProjection>
  26. {
  27. // fields
  28. private IEnumerable<ArrayFilterDefinition> _arrayFilters;
  29. private bool? _bypassDocumentValidation;
  30. private Collation _collation;
  31. private bool _isUpsert;
  32. private TimeSpan? _maxTime;
  33. private ProjectionDefinition<TDocument, TProjection> _projection;
  34. private ReturnDocument _returnDocument;
  35. private SortDefinition<TDocument> _sort;
  36. // constructors
  37. /// <summary>
  38. /// Initializes a new instance of the <see cref="FindOneAndUpdateOptions{TDocument, TProjection}"/> class.
  39. /// </summary>
  40. public FindOneAndUpdateOptions()
  41. {
  42. _returnDocument = ReturnDocument.Before;
  43. }
  44. // properties
  45. /// <summary>
  46. /// Gets or sets the array filters.
  47. /// </summary>
  48. /// <value>
  49. /// The array filters.
  50. /// </value>
  51. public IEnumerable<ArrayFilterDefinition> ArrayFilters
  52. {
  53. get { return _arrayFilters; }
  54. set { _arrayFilters = value; }
  55. }
  56. /// <summary>
  57. /// Gets or sets a value indicating whether to bypass document validation.
  58. /// </summary>
  59. public bool? BypassDocumentValidation
  60. {
  61. get { return _bypassDocumentValidation; }
  62. set { _bypassDocumentValidation = value; }
  63. }
  64. /// <summary>
  65. /// Gets or sets the collation.
  66. /// </summary>
  67. public Collation Collation
  68. {
  69. get { return _collation; }
  70. set { _collation = value; }
  71. }
  72. /// <summary>
  73. /// Gets or sets a value indicating whether to insert the document if it doesn't already exist.
  74. /// </summary>
  75. public bool IsUpsert
  76. {
  77. get { return _isUpsert; }
  78. set { _isUpsert = value; }
  79. }
  80. /// <summary>
  81. /// Gets or sets the maximum time.
  82. /// </summary>
  83. public TimeSpan? MaxTime
  84. {
  85. get { return _maxTime; }
  86. set { _maxTime = value; }
  87. }
  88. /// <summary>
  89. /// Gets or sets the projection.
  90. /// </summary>
  91. public ProjectionDefinition<TDocument, TProjection> Projection
  92. {
  93. get { return _projection; }
  94. set { _projection = value; }
  95. }
  96. /// <summary>
  97. /// Gets or sets which version of the document to return.
  98. /// </summary>
  99. public ReturnDocument ReturnDocument
  100. {
  101. get { return _returnDocument; }
  102. set { _returnDocument = value; }
  103. }
  104. /// <summary>
  105. /// Gets or sets the sort.
  106. /// </summary>
  107. public SortDefinition<TDocument> Sort
  108. {
  109. get { return _sort; }
  110. set { _sort = value; }
  111. }
  112. }
  113. /// <summary>
  114. /// Options for a findAndModify command to update an object.
  115. /// </summary>
  116. /// <typeparam name="TDocument">The type of the document and the result.</typeparam>
  117. public class FindOneAndUpdateOptions<TDocument> : FindOneAndUpdateOptions<TDocument, TDocument>
  118. {
  119. }
  120. }