This repository has been archived by the owner on Dec 30, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 228
/
IMongoCollection_1.cs
294 lines (258 loc) · 13.3 KB
/
IMongoCollection_1.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
using System;
using System.Collections.Generic;
namespace MongoDB
{
/// <summary>
/// A collection is a storage unit for a group of <see cref="Document"/>s. The documents do not all have to
/// contain the same schema but for efficiency they should all be similar.
/// </summary>
/// <remarks>Safemode checks the database for any errors that may have occurred during
/// the insert such as a duplicate key constraint violation.</remarks>
public interface IMongoCollection<T> where T : class
{
/// <summary>
/// Gets the database.
/// </summary>
/// <value>The database.</value>
IMongoDatabase Database { get; }
/// <summary>
/// Name of the collection.
/// </summary>
string Name { get; }
/// <summary>
/// String value of the database name.
/// </summary>
string DatabaseName { get; }
/// <summary>
/// Full name of the collection databasename . collectionname
/// </summary>
string FullName { get; }
/// <summary>
/// Metadata about the collection such as indexes.
/// </summary>
CollectionMetadata MetaData { get; }
/// <summary>
/// Finds and returns the first document in a query.
/// </summary>
/// <param name = "spec">A <see cref = "Document" /> representing the query.</param>
/// <returns>
/// A <see cref = "Document" /> from the collection.
/// </returns>
T FindOne(object spec);
/// <summary>
/// Returns a cursor that contains all of the documents in the collection.
/// </summary>
/// <remarks>Cursors load documents from the database in batches instead of all at once.</remarks>
ICursor<T> FindAll();
/// <summary>
/// Uses the $where operator to query the collection. The value of the where is Javascript that will
/// produce a true for the documents that match the criteria.
/// </summary>
/// <param name = "where">Javascript</param>
ICursor<T> Find(string where);
/// <summary>
/// Queries the collection using the specification.
/// </summary>
/// <param name = "spec">The spec.</param>
/// <returns>
/// A <see cref="ICursor"/>
/// </returns>
ICursor<T> Find(object spec);
/// <summary>
/// Queries the collection using the specification and only returns a subset of fields
/// from the <see cref="Document"/>.
/// </summary>
/// <returns>
/// A <see cref="ICursor"/>
/// </returns>
ICursor<T> Find(object spec, object fields);
/// <summary>
/// Deprecated. Use the fluent interface on the cursor to specify a limit and skip value.
/// </summary>
[Obsolete("Use the fluent interface on ICursor for specifying limit and skip Find.Skip(x).Limit(y)")]
ICursor<T> Find(object spec, int limit, int skip);
/// <summary>
/// Queries the collection using the specification and only returns a subset of fields
/// </summary>
[Obsolete("Use the fluent interface on ICursor for specifying limit and skip Find.Skip(x).Limit(y)")]
ICursor<T> Find(object spec, int limit, int skip, object fields);
/// <summary>
/// Executes a query and atomically applies a modifier operation to the first document returning the original document
/// by default.
/// </summary>
/// <param name="document">The document.</param>
/// <param name="spec"><see cref="Document"/> to find the document.</param>
/// <returns>A <see cref="Document"/></returns>
T FindAndModify(object document, object spec);
/// <summary>
/// Executes a query and atomically applies a modifier operation to the first document returning the original document
/// by default.
/// </summary>
/// <param name="document">The document.</param>
/// <param name="spec"><see cref="Document"/> to find the document.</param>
/// <param name="sort"><see cref="Document"/> containing the names of columns to sort on with the values being the</param>
/// <returns>A <see cref="Document"/></returns>
/// <see cref="IndexOrder"/>
T FindAndModify(object document, object spec, object sort);
/// <summary>
/// Executes a query and atomically applies a modifier operation to the first document returning the original document
/// by default.
/// </summary>
/// <param name="document">The document.</param>
/// <param name="spec"><see cref="Document"/> to find the document.</param>
/// <param name="returnNew">if set to <c>true</c> [return new].</param>
/// <returns>A <see cref="Document"/></returns>
T FindAndModify(object document, object spec, bool returnNew);
/// <summary>
/// Executes a query and atomically applies a modifier operation to the first document returning the original document
/// by default.
/// </summary>
/// <param name="document">The document.</param>
/// <param name="spec"><see cref="Document"/> to find the document.</param>
/// <param name="sort"><see cref="Document"/> containing the names of columns to sort on with the values being the
/// <see cref="IndexOrder"/></param>
/// <param name="returnNew">if set to <c>true</c> [return new].</param>
/// <returns>A <see cref="Document"/></returns>
T FindAndModify(object document, object spec, object sort, bool returnNew);
/// <summary>
/// Entrypoint into executing a map/reduce query against the collection.
/// </summary>
/// <returns></returns>
MapReduce MapReduce();
/// <summary>
/// Provides a fluent interface into building a map reduce command against the database.
/// </summary>
/// <returns></returns>
MapReduceBuilder MapReduceBuilder();
///<summary>
/// Count all items in the collection.
///</summary>
long Count();
/// <summary>
/// Count all items in a collection that match the query spec.
/// </summary>
/// <param name = "spec">The spec.</param>
/// <remarks>
/// It will return 0 if the collection doesn't exist yet.
/// </remarks>
long Count(object spec);
/// <summary>
/// Inserts the Document into the collection.
/// </summary>
void Insert(object document, bool safemode);
/// <summary>
/// Inserts the specified doc.
/// </summary>
/// <param name = "document">The doc.</param>
void Insert(object document);
/// <summary>
/// Bulk inserts the specified documents into the database.
/// </summary>
/// <remarks>See the safemode description in the class description</remarks>
void Insert<TElement>(IEnumerable<TElement> documents, bool safemode);
/// <summary>
/// Bulk inserts the specified documents into the database.
/// </summary>
/// <param name = "documents">The documents.</param>
void Insert<TElement>(IEnumerable<TElement> documents);
/// <summary>
/// Deletes documents from the collection according to the spec.
/// </summary>
/// <param name="selector">The selector.</param>
/// <param name="safemode">if set to <c>true</c> [safemode].</param>
/// <remarks>
/// An empty document will match all documents in the collection and effectively truncate it.
/// See the safemode description in the class description
/// </remarks>
void Delete(object selector, bool safemode);
/// <summary>
/// Deletes documents from the collection according to the spec.
/// </summary>
/// <param name = "selector">The selector.</param>
/// <remarks>
/// An empty document will match all documents in the collection and effectively truncate it.
/// </remarks>
void Delete(object selector);
/// <summary>
/// Inserts or updates a document in the database. If the document does not contain an _id one will be
/// generated and an upsert sent. Otherwise the document matching the _id of the document will be updated.
/// </summary>
/// <param name="document">The document.</param>
/// <param name="safemode">if set to <c>true</c> [safemode].</param>
/// <remarks>See the safemode description in the class description</remarks>
[Obsolete("Use Save instead")]
void Update(object document, bool safemode);
/// <summary>
/// Inserts or updates a document in the database. If the document does not contain an _id one will be
/// generated and an upsert sent. Otherwise the document matching the _id of the document will be updated.
/// </summary>
/// <param name = "document">The document.</param>
[Obsolete("Use Save instead")]
void Update(object document);
/// <summary>
/// Updates the specified document with the current document. In order to only do a partial update use a
/// document containing modifier operations ($set, $unset, $inc, etc.)
/// </summary>
/// <param name="document">The document.</param>
/// <param name="selector">The selector.</param>
/// <param name="safemode">if set to <c>true</c> [safemode].</param>
/// <remarks>See the safemode description in the class description</remarks>
void Update(object document, object selector, bool safemode);
/// <summary>
/// Updates the specified document with the current document. In order to only do a partial update use a
/// document containing modifier operations ($set, $unset, $inc, etc.)
/// </summary>
/// <param name = "document">The document.</param>
/// <param name = "selector">The selector.</param>
void Update(object document, object selector);
/// <summary>
/// Updates the specified document with the current document. In order to only do a partial update use a
/// document containing modifier operations ($set, $unset, $inc, etc.)
/// </summary>
/// <param name="document">The document.</param>
/// <param name="selector">The selector.</param>
/// <param name="flags">The flags.</param>
/// <param name="safemode">if set to <c>true</c> [safemode].</param>
/// <remarks>See the safemode description in the class description</remarks>
void Update(object document, object selector, UpdateFlags flags, bool safemode);
/// <summary>
/// Updates the specified document with the current document. In order to only do a partial update use a
/// document containing modifier operations ($set, $unset, $inc, etc.)
/// </summary>
/// <param name = "document">The <see cref = "Document" /> to update with</param>
/// <param name = "selector">The query spec to find the document to update.</param>
/// <param name = "flags"><see cref = "UpdateFlags" /></param>
void Update(object document, object selector, UpdateFlags flags);
/// <summary>
/// Runs a multiple update query against the database. It will wrap any
/// doc with $set if the passed in doc doesn't contain any '$' modifier ops.
/// </summary>
/// <param name = "document">The document.</param>
/// <param name = "selector">The selector.</param>
void UpdateAll(object document, object selector);
/// <summary>
/// Runs a multiple update query against the database. It will wrap any
/// doc with $set if the passed in doc doesn't contain any '$' modifier ops.
/// </summary>
/// <param name="document">The document.</param>
/// <param name="selector">The selector.</param>
/// <param name="safemode">if set to <c>true</c> [safemode].</param>
/// <remarks>See the safemode description in the class description</remarks>
void UpdateAll(object document, object selector, bool safemode);
/// <summary>
/// Inserts or updates a document in the database. If the document does not contain an _id one will be
/// generated and an upsert sent. Otherwise the document matching the _id of the document will be updated.
/// </summary>
/// <param name="document">The document.</param>
/// <remarks>
/// The document will contain the _id that is saved to the database.
/// </remarks>
void Save(object document);
/// <summary>
/// Saves a document to the database using an upsert.
/// </summary>
/// <param name="document">The document.</param>
/// <param name="safemode">if set to <c>true</c> [safemode].</param>
void Save(object document,bool safemode);
}
}