Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

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