1
- #nullable disable
2
- #pragma warning disable CA2227 // Collection properties should be read only
1
+ #pragma warning disable CA2227 // Collection properties should be read only
3
2
using System . Collections . Generic ;
4
3
using System . ComponentModel ;
5
4
using Newtonsoft . Json ;
@@ -16,162 +15,144 @@ public class CouchViewOptions<TKey>
16
15
/// Include conflicts information in response.
17
16
/// Ignored if <see cref="IncludeDocs"/> isn't <c>True</c>. Default is <c>False</c>.
18
17
/// </summary>
19
- [ JsonProperty ( "conflicts" ) ]
20
- [ DefaultValue ( false ) ]
21
- public bool Conflicts { get ; set ; }
18
+ [ JsonProperty ( "conflicts" , NullValueHandling = NullValueHandling . Ignore ) ]
19
+ public bool ? Conflicts { get ; set ; }
22
20
23
21
/// <summary>
24
22
/// Return the documents in descending order by key. Default is <c>False</c>.
25
23
/// </summary>
26
- [ JsonProperty ( "descending" ) ]
27
- [ DefaultValue ( false ) ]
28
- public bool Descending { get ; set ; }
24
+ [ JsonProperty ( "descending" , NullValueHandling = NullValueHandling . Ignore ) ]
25
+ public bool ? Descending { get ; set ; }
29
26
30
27
/// <summary>
31
28
/// Stop returning records when the specified key is reached.
32
29
/// </summary>
33
- [ JsonProperty ( "endkey" ) ]
34
- [ DefaultValue ( null ) ]
35
- public TKey EndKey { get ; set ; }
30
+ [ JsonProperty ( "endkey" , NullValueHandling = NullValueHandling . Ignore ) ]
31
+ public TKey ? EndKey { get ; set ; }
36
32
37
33
/// <summary>
38
34
/// Stop returning records when the specified document ID is reached.
39
35
/// Ignored if <see cref="EndKey"/> is not set.
40
36
/// </summary>
41
- [ JsonProperty ( "endkey_docid" ) ]
42
- [ DefaultValue ( null ) ]
43
- public string EndKeyDocId { get ; set ; }
37
+ [ JsonProperty ( "endkey_docid" , NullValueHandling = NullValueHandling . Ignore ) ]
38
+ public string ? EndKeyDocId { get ; set ; }
44
39
45
40
/// <summary>
46
41
/// Group the results using the reduce function to a group or single row.
47
42
/// Implies reduce is <c>True</c> and the maximum <see cref="GroupLevel"/>. Default is <c>False</c>.
48
43
/// </summary>
49
- [ JsonProperty ( "group" ) ]
50
- [ DefaultValue ( false ) ]
51
- public bool Group { get ; set ; }
44
+ [ JsonProperty ( "group" , NullValueHandling = NullValueHandling . Ignore ) ]
45
+ public bool ? Group { get ; set ; }
52
46
53
47
/// <summary>
54
48
/// Specify the group level to be used. Implies group is <c>True</c>.
55
49
/// </summary>
56
- [ JsonProperty ( "group_level" ) ]
57
- [ DefaultValue ( null ) ]
50
+ [ JsonProperty ( "group_level" , NullValueHandling = NullValueHandling . Ignore ) ]
58
51
public int ? GroupLevel { get ; set ; }
59
52
60
53
/// <summary>
61
54
/// Include the associated document with each row. Default is <c>False</c>.
62
55
/// </summary>
63
- [ JsonProperty ( "include_docs" ) ]
64
- [ DefaultValue ( false ) ]
65
- public bool IncludeDocs { get ; set ; }
56
+ [ JsonProperty ( "include_docs" , NullValueHandling = NullValueHandling . Ignore ) ]
57
+ public bool ? IncludeDocs { get ; set ; }
66
58
67
59
/// <summary>
68
60
/// Include the Base64-encoded content of attachments in the documents that are included if <see cref="IncludeDocs"/> is <c>True</c>.
69
61
/// Ignored if <see cref="IncludeDocs"/> isn’t <c>True</c>. Default is <c>False</c>.
70
62
/// </summary>
71
- [ JsonProperty ( "attachments" ) ]
72
- [ DefaultValue ( false ) ]
73
- public bool Attachments { get ; set ; }
63
+ [ JsonProperty ( "attachments" , NullValueHandling = NullValueHandling . Ignore ) ]
64
+ public bool ? Attachments { get ; set ; }
74
65
75
66
/// <summary>
76
67
/// Include encoding information in attachment stubs if <see cref="IncludeDocs"/> is <c>True</c> and the particular attachment is compressed.
77
68
/// Ignored if <see cref="IncludeDocs"/> isn’t <c>True</c>. Default is <c>False</c>.
78
69
/// </summary>
79
- [ JsonProperty ( "att_encoding_info" ) ]
80
- [ DefaultValue ( false ) ]
81
- public bool AttachEncodingInfo { get ; set ; }
70
+ [ JsonProperty ( "att_encoding_info" , NullValueHandling = NullValueHandling . Ignore ) ]
71
+ public bool ? AttachEncodingInfo { get ; set ; }
82
72
83
73
/// <summary>
84
74
/// Specifies whether the specified end key should be included in the result. Default is <c>True</c>.
85
75
/// </summary>
86
- [ JsonProperty ( "inclusive_end" ) ]
87
- [ DefaultValue ( true ) ]
88
- public bool InclusiveEnd { get ; set ; } = true ;
76
+ [ JsonProperty ( "inclusive_end" , NullValueHandling = NullValueHandling . Ignore ) ]
77
+ public bool ? InclusiveEnd { get ; set ; }
89
78
90
79
/// <summary>
91
80
/// Return only documents that match the specified key.
92
81
/// </summary>
93
- [ JsonProperty ( "key" ) ]
94
- [ DefaultValue ( null ) ]
95
- public TKey Key { get ; set ; }
82
+ [ JsonProperty ( "key" , NullValueHandling = NullValueHandling . Ignore ) ]
83
+ public TKey ? Key { get ; set ; }
96
84
97
85
/// <summary>
98
86
/// Return only documents where the key matches one of the keys specified in the array.
99
87
/// </summary>
100
- [ JsonProperty ( "keys" ) ]
101
- [ DefaultValue ( null ) ]
102
- public IList < TKey > Keys { get ; set ; }
88
+ [ JsonProperty ( "keys" , NullValueHandling = NullValueHandling . Ignore ) ]
89
+ public IList < TKey > ? Keys { get ; set ; }
103
90
104
91
/// <summary>
105
92
/// Limit the number of the returned documents to the specified number.
106
93
/// </summary>
107
- [ JsonProperty ( "limit" ) ]
108
- [ DefaultValue ( null ) ]
94
+ [ JsonProperty ( "limit" , NullValueHandling = NullValueHandling . Ignore ) ]
109
95
public int ? Limit { get ; set ; }
110
96
111
97
/// <summary>
112
98
/// Use the reduction function. Default is <c>True</c> when a reduce function is defined.
113
99
/// </summary>
114
- [ JsonProperty ( "reduce" ) ]
115
- [ DefaultValue ( false ) ]
116
- public bool Reduce { get ; set ; }
100
+ [ JsonProperty ( "reduce" , NullValueHandling = NullValueHandling . Ignore ) ]
101
+ public bool ? Reduce { get ; set ; }
117
102
118
103
/// <summary>
119
104
/// Skip this number of records before starting to return the results. Default is <code>0</code>.
120
105
/// </summary>
121
- [ JsonProperty ( "skip" ) ]
122
- [ DefaultValue ( 0 ) ]
123
- public int Skip { get ; set ; }
106
+ [ JsonProperty ( "skip" , NullValueHandling = NullValueHandling . Ignore ) ]
107
+ public int ? Skip { get ; set ; }
124
108
125
109
/// <summary>
126
110
/// Sort returned rows (see Sorting <see href="https://docs.couchdb.org/en/stable/api/ddoc/views.html#api-ddoc-view-sorting"></see> Returned Rows).
127
111
/// Setting this to false offers a performance boost.
128
112
/// The <see cref="CouchViewResult{TKey, TRow}.TotalRows"/> and <see cref="CouchViewResult{TKey, TRow}.Offset"/> fields are not available when this is set to <c>False</c>.
129
113
/// Default is <c>True</c>.
130
114
/// </summary>
131
- [ JsonProperty ( "sorted" ) ]
132
- [ DefaultValue ( true ) ]
133
- public bool Sorted { get ; set ; } = true ;
115
+ [ JsonProperty ( "sorted" , NullValueHandling = NullValueHandling . Ignore ) ]
116
+ public bool ? Sorted { get ; set ; }
134
117
135
118
/// <summary>
136
- /// Whether or not the view results should be returned from a stable set of shards. Default is <c>False</c>.
119
+ /// Whether or not the view results should be returned from a stable set of shards.
120
+ /// Supported values <see cref="StableStyle.True"/>, <see cref="StableStyle.False"/>. Default is <see cref="StableStyle.False"/>
137
121
/// </summary>
138
- [ JsonProperty ( "stable" ) ]
139
- [ DefaultValue ( false ) ]
140
- public bool Stable { get ; set ; }
122
+ [ JsonIgnore ]
123
+ public StableStyle ? Stable { get ; set ; }
124
+
125
+ [ JsonProperty ( "stable" , NullValueHandling = NullValueHandling . Ignore ) ]
126
+ internal string ? StableString => Stable ? . ToString ( ) ;
141
127
142
128
/// <summary>
143
129
/// Return records starting with the specified key.
144
130
/// </summary>
145
- [ JsonProperty ( "startkey" ) ]
146
- [ DefaultValue ( null ) ]
147
- public TKey StartKey { get ; set ; }
131
+ [ JsonProperty ( "startkey" , NullValueHandling = NullValueHandling . Ignore ) ]
132
+ public TKey ? StartKey { get ; set ; }
148
133
149
134
/// <summary>
150
135
/// Return records starting with the specified document ID. Ignored if <see cref="StartKey"/> is not set.
151
136
/// </summary>
152
- [ JsonProperty ( "startkey_docid" ) ]
153
- [ DefaultValue ( null ) ]
154
- public string StartKeyDocId { get ; set ; }
137
+ [ JsonProperty ( "startkey_docid" , NullValueHandling = NullValueHandling . Ignore ) ]
138
+ public string ? StartKeyDocId { get ; set ; }
155
139
156
140
/// <summary>
157
141
/// Whether or not the view in question should be updated prior to responding to the user.
158
142
/// Supported values: <see cref="UpdateStyle.True"/>, <see cref="UpdateStyle.False"/>, <see cref="UpdateStyle.Lazy"/>. Default is <see cref="UpdateStyle.True"/>.
159
143
/// </summary>
160
144
[ JsonIgnore ]
161
- public UpdateStyle Update { get ; set ; } = UpdateStyle . True ;
145
+ public UpdateStyle ? Update { get ; set ; }
162
146
163
- [ JsonProperty ( "update" ) ]
164
- [ DefaultValue ( "true" ) ]
165
- internal string UpdateString => Update . ToString ( ) ;
147
+ [ JsonProperty ( "update" , NullValueHandling = NullValueHandling . Ignore ) ]
148
+ internal string ? UpdateString => Update ? . ToString ( ) ;
166
149
167
150
/// <summary>
168
151
/// Whether to include in the response an <see cref="UpdateSeq"/> value indicating the sequence id of the database the view reflects.
169
152
/// Default is <c>False</c>.
170
153
/// </summary>
171
- [ JsonProperty ( "update_seq" ) ]
172
- [ DefaultValue ( false ) ]
173
- public bool UpdateSeq { get ; set ; }
154
+ [ JsonProperty ( "update_seq" , NullValueHandling = NullValueHandling . Ignore ) ]
155
+ public bool ? UpdateSeq { get ; set ; }
174
156
}
175
157
}
176
158
#pragma warning restore CA2227 // Collection properties should be read only
177
- #nullable restore
0 commit comments