1 /*
2 * #%L
3 * AsyncMongoCollection.java - mongodb-async-driver - Allanbank Consulting, Inc.
4 * %%
5 * Copyright (C) 2011 - 2014 Allanbank Consulting, Inc.
6 * %%
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * #L%
19 */
20 package com.allanbank.mongodb;
21
22 import java.util.Collection;
23
24 import com.allanbank.mongodb.bson.Document;
25 import com.allanbank.mongodb.bson.DocumentAssignable;
26 import com.allanbank.mongodb.bson.Element;
27 import com.allanbank.mongodb.bson.impl.EmptyDocument;
28 import com.allanbank.mongodb.builder.Aggregate;
29 import com.allanbank.mongodb.builder.BatchedWrite;
30 import com.allanbank.mongodb.builder.ConditionBuilder;
31 import com.allanbank.mongodb.builder.Count;
32 import com.allanbank.mongodb.builder.Distinct;
33 import com.allanbank.mongodb.builder.Find;
34 import com.allanbank.mongodb.builder.FindAndModify;
35 import com.allanbank.mongodb.builder.GroupBy;
36 import com.allanbank.mongodb.builder.MapReduce;
37 import com.allanbank.mongodb.builder.ParallelScan;
38
39 /**
40 * Interface for asynchronously interacting with a MongoDB collection.
41 * <p>
42 * The synchronous methods for interacting with a collection are declared as
43 * part of the {@link MongoCollection} interface (which extends this interface.
44 * </p>
45 *
46 * @api.yes This interface is part of the driver's API. Public and protected
47 * members will be deprecated for at least 1 non-bugfix release
48 * (version numbers are <major>.<minor>.<bugfix>)
49 * before being removed or modified.
50 * @copyright 2014, Allanbank Consulting, Inc., All Rights Reserved
51 *
52 * @see MongoCollection
53 */
54 public interface AsyncMongoCollection {
55 /** An (empty) query document to find all documents. */
56 public static final Document ALL = EmptyDocument.INSTANCE;
57
58 /** An (empty) update document to perform no actual modifications. */
59 public static final Document NONE = AsyncMongoCollection.ALL;
60
61 /**
62 * Invokes a aggregate command on the server.
63 *
64 * @param command
65 * The details of the aggregation request.
66 * @return ListenableFuture for the aggregation results returned.
67 * @throws MongoDbException
68 * On an error executing the aggregate command.
69 */
70 public ListenableFuture<MongoIterator<Document>> aggregateAsync(
71 Aggregate command) throws MongoDbException;
72
73 /**
74 * Invokes a aggregate command on the server.
75 *
76 * @param command
77 * The details of the aggregation request.
78 * @return ListenableFuture for the aggregation results returned.
79 * @throws MongoDbException
80 * On an error executing the aggregate command.
81 */
82 public ListenableFuture<MongoIterator<Document>> aggregateAsync(
83 Aggregate.Builder command) throws MongoDbException;
84
85 /**
86 * Invokes a aggregate command on the server.
87 *
88 * @param results
89 * Callback for the aggregation results returned.
90 * @param command
91 * The details of the aggregation request.
92 * @throws MongoDbException
93 * On an error executing the aggregate command.
94 */
95 public void aggregateAsync(Callback<MongoIterator<Document>> results,
96 Aggregate command) throws MongoDbException;
97
98 /**
99 * Invokes a aggregate command on the server.
100 *
101 * @param results
102 * Callback for the aggregation results returned.
103 * @param command
104 * The details of the aggregation request.
105 * @throws MongoDbException
106 * On an error executing the aggregate command.
107 */
108 public void aggregateAsync(Callback<MongoIterator<Document>> results,
109 Aggregate.Builder command) throws MongoDbException;
110
111 /**
112 * Invokes a aggregate command on the server.
113 *
114 * @param results
115 * Callback for the aggregation results returned.
116 * @param command
117 * The details of the aggregation request.
118 * @throws MongoDbException
119 * On an error executing the aggregate command.
120 */
121 public void aggregateAsync(LambdaCallback<MongoIterator<Document>> results,
122 Aggregate command) throws MongoDbException;
123
124 /**
125 * Invokes a aggregate command on the server.
126 *
127 * @param results
128 * Callback for the aggregation results returned.
129 * @param command
130 * The details of the aggregation request.
131 * @throws MongoDbException
132 * On an error executing the aggregate command.
133 */
134 public void aggregateAsync(LambdaCallback<MongoIterator<Document>> results,
135 Aggregate.Builder command) throws MongoDbException;
136
137 /**
138 * Counts the set of documents in the collection.
139 * <p>
140 * This is equivalent to calling {@link #countAsync() countAsync().get()}
141 * </p>
142 *
143 * @return The number of documents in the collection.
144 * @throws MongoDbException
145 * On an error finding the documents.
146 */
147 public ListenableFuture<Long> countAsync() throws MongoDbException;
148
149 /**
150 * Counts the set of documents in the collection.
151 * <p>
152 * This is equivalent to calling
153 * {@link #countAsync(Callback, DocumentAssignable) countAsync(results,
154 * BuilderFactory.start())}
155 * </p>
156 *
157 * @param results
158 * The callback to notify of the results.
159 * @throws MongoDbException
160 * On an error finding the documents.
161 */
162 public void countAsync(Callback<Long> results) throws MongoDbException;
163
164 /**
165 * Counts the set of documents matching the query document in the
166 * collection.
167 *
168 * @param results
169 * The callback to notify of the results.
170 * @param count
171 * The count command.
172 * @throws MongoDbException
173 * On an error counting the documents.
174 */
175 public void countAsync(Callback<Long> results, Count count)
176 throws MongoDbException;
177
178 /**
179 * Counts the set of documents matching the query document in the
180 * collection.
181 *
182 * @param results
183 * The callback to notify of the results.
184 * @param count
185 * The count command.
186 * @throws MongoDbException
187 * On an error counting the documents.
188 */
189 public void countAsync(Callback<Long> results, Count.Builder count)
190 throws MongoDbException;
191
192 /**
193 * Counts the set of documents matching the query document in the
194 * collection.
195 *
196 * @param results
197 * The callback to notify of the results.
198 * @param query
199 * The query document.
200 * @throws MongoDbException
201 * On an error finding the documents.
202 */
203 public void countAsync(Callback<Long> results, DocumentAssignable query)
204 throws MongoDbException;
205
206 /**
207 * Counts the set of documents matching the query document in the
208 * collection.
209 *
210 * @param results
211 * The callback to notify of the results.
212 * @param query
213 * The query document.
214 * @param readPreference
215 * The preference for which servers to use to retrieve the
216 * results.
217 * @throws MongoDbException
218 * On an error finding the documents.
219 */
220 public void countAsync(Callback<Long> results, DocumentAssignable query,
221 ReadPreference readPreference) throws MongoDbException;
222
223 /**
224 * Counts the set of documents in the collection.
225 * <p>
226 * This is equivalent to calling
227 * {@link #countAsync(Callback, DocumentAssignable) countAsync(results,
228 * BuilderFactory.start(), readPreference)}
229 * </p>
230 *
231 * @param results
232 * The callback to notify of the results.
233 * @param readPreference
234 * The preference for which servers to use to retrieve the
235 * results.
236 * @throws MongoDbException
237 * On an error finding the documents.
238 */
239 public void countAsync(Callback<Long> results, ReadPreference readPreference)
240 throws MongoDbException;
241
242 /**
243 * Counts the set of documents matching the query document in the
244 * collection.
245 *
246 * @param count
247 * The count command.
248 * @return The future that will be updated with the count once it is
249 * completed.
250 * @throws MongoDbException
251 * On an error counting the documents.
252 */
253 public ListenableFuture<Long> countAsync(Count count)
254 throws MongoDbException;
255
256 /**
257 * Counts the set of documents matching the query document in the
258 * collection.
259 *
260 * @param count
261 * The count command.
262 * @return The future that will be updated with the count once it is
263 * completed.
264 * @throws MongoDbException
265 * On an error counting the documents.
266 */
267 public ListenableFuture<Long> countAsync(Count.Builder count)
268 throws MongoDbException;
269
270 /**
271 * Counts the set of documents matching the query document in the
272 * collection.
273 *
274 * @param query
275 * The query document.
276 * @return A future that will be updated with the number of matching
277 * documents.
278 * @throws MongoDbException
279 * On an error finding the documents.
280 */
281 public ListenableFuture<Long> countAsync(DocumentAssignable query)
282 throws MongoDbException;
283
284 /**
285 * Counts the set of documents matching the query document in the
286 * collection.
287 *
288 * @param query
289 * The query document.
290 * @param readPreference
291 * The preference for which servers to use to retrieve the
292 * results.
293 * @return A future that will be updated with the number of matching
294 * documents.
295 * @throws MongoDbException
296 * On an error finding the documents.
297 */
298 public ListenableFuture<Long> countAsync(DocumentAssignable query,
299 ReadPreference readPreference) throws MongoDbException;
300
301 /**
302 * Counts the set of documents in the collection.
303 * <p>
304 * This is equivalent to calling
305 * {@link #countAsync(LambdaCallback, DocumentAssignable)
306 * countAsync(results, BuilderFactory.start())}
307 * </p>
308 *
309 * @param results
310 * The callback to notify of the results.
311 * @throws MongoDbException
312 * On an error finding the documents.
313 */
314 public void countAsync(LambdaCallback<Long> results)
315 throws MongoDbException;
316
317 /**
318 * Counts the set of documents matching the query document in the
319 * collection.
320 *
321 * @param results
322 * The callback to notify of the results.
323 * @param count
324 * The count command.
325 * @throws MongoDbException
326 * On an error counting the documents.
327 */
328 public void countAsync(LambdaCallback<Long> results, Count count)
329 throws MongoDbException;
330
331 /**
332 * Counts the set of documents matching the query document in the
333 * collection.
334 *
335 * @param results
336 * The callback to notify of the results.
337 * @param count
338 * The count command.
339 * @throws MongoDbException
340 * On an error counting the documents.
341 */
342 public void countAsync(LambdaCallback<Long> results, Count.Builder count)
343 throws MongoDbException;
344
345 /**
346 * Counts the set of documents matching the query document in the
347 * collection.
348 *
349 * @param results
350 * The callback to notify of the results.
351 * @param query
352 * The query document.
353 * @throws MongoDbException
354 * On an error finding the documents.
355 */
356 public void countAsync(LambdaCallback<Long> results,
357 DocumentAssignable query) throws MongoDbException;
358
359 /**
360 * Counts the set of documents matching the query document in the
361 * collection.
362 *
363 * @param results
364 * The callback to notify of the results.
365 * @param query
366 * The query document.
367 * @param readPreference
368 * The preference for which servers to use to retrieve the
369 * results.
370 * @throws MongoDbException
371 * On an error finding the documents.
372 */
373 public void countAsync(LambdaCallback<Long> results,
374 DocumentAssignable query, ReadPreference readPreference)
375 throws MongoDbException;
376
377 /**
378 * Counts the set of documents in the collection.
379 * <p>
380 * This is equivalent to calling
381 * {@link #countAsync(LambdaCallback, DocumentAssignable)
382 * countAsync(results, BuilderFactory.start(), readPreference)}
383 * </p>
384 *
385 * @param results
386 * The callback to notify of the results.
387 * @param readPreference
388 * The preference for which servers to use to retrieve the
389 * results.
390 * @throws MongoDbException
391 * On an error finding the documents.
392 */
393 public void countAsync(LambdaCallback<Long> results,
394 ReadPreference readPreference) throws MongoDbException;
395
396 /**
397 * Counts the set of documents in the collection.
398 * <p>
399 * This is equivalent to calling {@link #countAsync() countAsync().get()}
400 * </p>
401 *
402 * @param readPreference
403 * The preference for which servers to use to retrieve the
404 * results.
405 * @return The number of documents in the collection.
406 * @throws MongoDbException
407 * On an error finding the documents.
408 */
409 public ListenableFuture<Long> countAsync(ReadPreference readPreference)
410 throws MongoDbException;
411
412 /**
413 * Deletes a set of documents matching a query from the collection.
414 *
415 * @param results
416 * Callback that will be notified of the results of the query. If
417 * the durability of the operation is NONE then this will be -1.
418 * @param query
419 * Query to locate the documents to be deleted.
420 * @throws MongoDbException
421 * On an error deleting the documents.
422 */
423 public void deleteAsync(Callback<Long> results, DocumentAssignable query)
424 throws MongoDbException;
425
426 /**
427 * Deletes a set of documents matching a query from the collection.
428 *
429 * @param results
430 * Callback that will be notified of the results of the query. If
431 * the durability of the operation is NONE then this will be -1.
432 * @param query
433 * Query to locate the documents to be deleted.
434 * @param singleDelete
435 * If true then only a single document will be deleted. If
436 * running in a sharded environment then this field must be false
437 * or the query must contain the shard key.
438 * @throws MongoDbException
439 * On an error deleting the documents.
440 */
441 public void deleteAsync(Callback<Long> results, DocumentAssignable query,
442 boolean singleDelete) throws MongoDbException;
443
444 /**
445 * Deletes a set of documents matching a query from the collection.
446 *
447 * @param results
448 * Callback that will be notified of the results of the query. If
449 * the durability of the operation is NONE then this will be -1.
450 * @param query
451 * Query to locate the documents to be deleted.
452 * @param singleDelete
453 * If true then only a single document will be deleted. If
454 * running in a sharded environment then this field must be false
455 * or the query must contain the shard key.
456 * @param durability
457 * The durability for the delete.
458 * @throws MongoDbException
459 * On an error deleting the documents.
460 */
461 public void deleteAsync(Callback<Long> results, DocumentAssignable query,
462 boolean singleDelete, Durability durability)
463 throws MongoDbException;
464
465 /**
466 * Deletes a set of documents matching a query from the collection.
467 *
468 * @param results
469 * Callback that will be notified of the results of the query. If
470 * the durability of the operation is NONE then this will be -1.
471 * @param query
472 * Query to locate the documents to be deleted.
473 * @param durability
474 * The durability for the delete.
475 * @throws MongoDbException
476 * On an error deleting the documents.
477 */
478 public void deleteAsync(Callback<Long> results, DocumentAssignable query,
479 Durability durability) throws MongoDbException;
480
481 /**
482 * Deletes a set of documents matching a query from the collection.
483 *
484 * @param query
485 * Query to locate the documents to be deleted.
486 * @return ListenableFuture that will be updated with the results of the
487 * delete. If the durability of the operation is NONE then this will
488 * be -1.
489 * @throws MongoDbException
490 * On an error deleting the documents.
491 */
492 public ListenableFuture<Long> deleteAsync(DocumentAssignable query)
493 throws MongoDbException;
494
495 /**
496 * Deletes a set of documents matching a query from the collection.
497 *
498 * @param query
499 * Query to locate the documents to be deleted.
500 * @param singleDelete
501 * If true then only a single document will be deleted. If
502 * running in a sharded environment then this field must be false
503 * or the query must contain the shard key.
504 * @return ListenableFuture that will be updated with the results of the
505 * delete. If the durability of the operation is NONE then this will
506 * be -1.
507 * @throws MongoDbException
508 * On an error deleting the documents.
509 */
510 public ListenableFuture<Long> deleteAsync(DocumentAssignable query,
511 boolean singleDelete) throws MongoDbException;
512
513 /**
514 * Deletes a set of documents matching a query from the collection.
515 *
516 * @param query
517 * Query to locate the documents to be deleted.
518 * @param singleDelete
519 * If true then only a single document will be deleted. If
520 * running in a sharded environment then this field must be false
521 * or the query must contain the shard key.
522 * @param durability
523 * The durability for the delete.
524 * @return ListenableFuture that will be updated with the results of the
525 * delete. If the durability of the operation is NONE then this will
526 * be -1.
527 * @throws MongoDbException
528 * On an error deleting the documents.
529 */
530 public ListenableFuture<Long> deleteAsync(DocumentAssignable query,
531 boolean singleDelete, Durability durability)
532 throws MongoDbException;
533
534 /**
535 * Deletes a set of documents matching a query from the collection.
536 *
537 * @param query
538 * Query to locate the documents to be deleted.
539 * @param durability
540 * The durability for the delete.
541 * @return ListenableFuture that will be updated with the results of the
542 * delete. If the durability of the operation is NONE then this will
543 * be -1.
544 * @throws MongoDbException
545 * On an error deleting the documents.
546 */
547 public ListenableFuture<Long> deleteAsync(DocumentAssignable query,
548 Durability durability) throws MongoDbException;
549
550 /**
551 * Deletes a set of documents matching a query from the collection.
552 *
553 * @param results
554 * Callback that will be notified of the results of the query. If
555 * the durability of the operation is NONE then this will be -1.
556 * @param query
557 * Query to locate the documents to be deleted.
558 * @throws MongoDbException
559 * On an error deleting the documents.
560 */
561 public void deleteAsync(LambdaCallback<Long> results,
562 DocumentAssignable query) throws MongoDbException;
563
564 /**
565 * Deletes a set of documents matching a query from the collection.
566 *
567 * @param results
568 * Callback that will be notified of the results of the query. If
569 * the durability of the operation is NONE then this will be -1.
570 * @param query
571 * Query to locate the documents to be deleted.
572 * @param singleDelete
573 * If true then only a single document will be deleted. If
574 * running in a sharded environment then this field must be false
575 * or the query must contain the shard key.
576 * @throws MongoDbException
577 * On an error deleting the documents.
578 */
579 public void deleteAsync(LambdaCallback<Long> results,
580 DocumentAssignable query, boolean singleDelete)
581 throws MongoDbException;
582
583 /**
584 * Deletes a set of documents matching a query from the collection.
585 *
586 * @param results
587 * Callback that will be notified of the results of the query. If
588 * the durability of the operation is NONE then this will be -1.
589 * @param query
590 * Query to locate the documents to be deleted.
591 * @param singleDelete
592 * If true then only a single document will be deleted. If
593 * running in a sharded environment then this field must be false
594 * or the query must contain the shard key.
595 * @param durability
596 * The durability for the delete.
597 * @throws MongoDbException
598 * On an error deleting the documents.
599 */
600 public void deleteAsync(LambdaCallback<Long> results,
601 DocumentAssignable query, boolean singleDelete,
602 Durability durability) throws MongoDbException;
603
604 /**
605 * Deletes a set of documents matching a query from the collection.
606 *
607 * @param results
608 * Callback that will be notified of the results of the query. If
609 * the durability of the operation is NONE then this will be -1.
610 * @param query
611 * Query to locate the documents to be deleted.
612 * @param durability
613 * The durability for the delete.
614 * @throws MongoDbException
615 * On an error deleting the documents.
616 */
617 public void deleteAsync(LambdaCallback<Long> results,
618 DocumentAssignable query, Durability durability)
619 throws MongoDbException;
620
621 /**
622 * Invokes a distinct command on the server.
623 *
624 * @param results
625 * Callback for the distinct results returned.
626 * @param command
627 * The details of the distinct request.
628 * @throws MongoDbException
629 * On an error finding the documents.
630 */
631 public void distinctAsync(Callback<MongoIterator<Element>> results,
632 Distinct command) throws MongoDbException;
633
634 /**
635 * Invokes a distinct command on the server.
636 *
637 * @param results
638 * Callback for the distinct results returned.
639 * @param command
640 * The details of the distinct request.
641 * @throws MongoDbException
642 * On an error finding the documents.
643 */
644 public void distinctAsync(Callback<MongoIterator<Element>> results,
645 Distinct.Builder command) throws MongoDbException;
646
647 /**
648 * Invokes a distinct command on the server.
649 *
650 * @param command
651 * The details of the distinct request.
652 * @return ListenableFuture for the distinct results returned.
653 * @throws MongoDbException
654 * On an error finding the documents.
655 */
656 public ListenableFuture<MongoIterator<Element>> distinctAsync(
657 Distinct command) throws MongoDbException;
658
659 /**
660 * Invokes a distinct command on the server.
661 *
662 * @param command
663 * The details of the distinct request.
664 * @return ListenableFuture for the distinct results returned.
665 * @throws MongoDbException
666 * On an error finding the documents.
667 */
668 public ListenableFuture<MongoIterator<Element>> distinctAsync(
669 Distinct.Builder command) throws MongoDbException;
670
671 /**
672 * Invokes a distinct command on the server.
673 *
674 * @param results
675 * Callback for the distinct results returned.
676 * @param command
677 * The details of the distinct request.
678 * @throws MongoDbException
679 * On an error finding the documents.
680 */
681 public void distinctAsync(LambdaCallback<MongoIterator<Element>> results,
682 Distinct command) throws MongoDbException;
683
684 /**
685 * Invokes a distinct command on the server.
686 *
687 * @param results
688 * Callback for the distinct results returned.
689 * @param command
690 * The details of the distinct request.
691 * @throws MongoDbException
692 * On an error finding the documents.
693 */
694 public void distinctAsync(LambdaCallback<MongoIterator<Element>> results,
695 Distinct.Builder command) throws MongoDbException;
696
697 /**
698 * Explains the way that the aggregation will be performed.
699 *
700 * @param aggregation
701 * The aggregation details.
702 * @return The document describing the method used to execute the query.
703 * @throws MongoDbException
704 * On an error finding the documents.
705 * @since MongoDB 2.6
706 */
707 public ListenableFuture<Document> explainAsync(Aggregate aggregation)
708 throws MongoDbException;
709
710 /**
711 * Explains the way that the aggregation will be performed.
712 *
713 * @param aggregation
714 * The aggregation details.
715 * @return The document describing the method used to execute the query.
716 * @throws MongoDbException
717 * On an error finding the documents.
718 * @since MongoDB 2.6
719 */
720 public ListenableFuture<Document> explainAsync(Aggregate.Builder aggregation)
721 throws MongoDbException;
722
723 /**
724 * Explains the way that the aggregation will be performed.
725 *
726 * @param aggregation
727 * The aggregation details.
728 * @param results
729 * Callback that will be notified of the results of the explain.
730 * @throws MongoDbException
731 * On an error finding the documents.
732 * @since MongoDB 2.6
733 */
734 public void explainAsync(Callback<Document> results, Aggregate aggregation)
735 throws MongoDbException;
736
737 /**
738 * Explains the way that the aggregation will be performed.
739 *
740 * @param aggregation
741 * The aggregation details.
742 * @param results
743 * Callback that will be notified of the results of the explain.
744 * @throws MongoDbException
745 * On an error finding the documents.
746 * @since MongoDB 2.6
747 */
748 public void explainAsync(Callback<Document> results,
749 Aggregate.Builder aggregation) throws MongoDbException;
750
751 /**
752 * Explains the way that the query will be performed.
753 *
754 * @param query
755 * The query details.
756 * @param results
757 * Callback that will be notified of the results of the explain.
758 * @throws MongoDbException
759 * On an error finding the documents.
760 */
761 public void explainAsync(Callback<Document> results, Find query)
762 throws MongoDbException;
763
764 /**
765 * Explains the way that the query will be performed.
766 *
767 * @param query
768 * The query details.
769 * @param results
770 * Callback that will be notified of the results of the explain.
771 * @throws MongoDbException
772 * On an error finding the documents.
773 */
774 public void explainAsync(Callback<Document> results, Find.Builder query)
775 throws MongoDbException;
776
777 /**
778 * Explains the way that the document will be performed.
779 *
780 * @param query
781 * The query details.
782 * @return The document describing the method used to execute the query.
783 * @throws MongoDbException
784 * On an error finding the documents.
785 */
786 public ListenableFuture<Document> explainAsync(Find query)
787 throws MongoDbException;
788
789 /**
790 * Explains the way that the document will be performed.
791 *
792 * @param query
793 * The query details.
794 * @return The document describing the method used to execute the query.
795 * @throws MongoDbException
796 * On an error finding the documents.
797 */
798 public ListenableFuture<Document> explainAsync(Find.Builder query)
799 throws MongoDbException;
800
801 /**
802 * Explains the way that the aggregation will be performed.
803 *
804 * @param aggregation
805 * The aggregation details.
806 * @param results
807 * Callback that will be notified of the results of the explain.
808 * @throws MongoDbException
809 * On an error finding the documents.
810 * @since MongoDB 2.6
811 */
812 public void explainAsync(LambdaCallback<Document> results,
813 Aggregate aggregation) throws MongoDbException;
814
815 /**
816 * Explains the way that the aggregation will be performed.
817 *
818 * @param aggregation
819 * The aggregation details.
820 * @param results
821 * Callback that will be notified of the results of the explain.
822 * @throws MongoDbException
823 * On an error finding the documents.
824 * @since MongoDB 2.6
825 */
826 public void explainAsync(LambdaCallback<Document> results,
827 Aggregate.Builder aggregation) throws MongoDbException;
828
829 /**
830 * Explains the way that the query will be performed.
831 *
832 * @param query
833 * The query details.
834 * @param results
835 * Callback that will be notified of the results of the explain.
836 * @throws MongoDbException
837 * On an error finding the documents.
838 */
839 public void explainAsync(LambdaCallback<Document> results, Find query)
840 throws MongoDbException;
841
842 /**
843 * Explains the way that the query will be performed.
844 *
845 * @param query
846 * The query details.
847 * @param results
848 * Callback that will be notified of the results of the explain.
849 * @throws MongoDbException
850 * On an error finding the documents.
851 */
852 public void explainAsync(LambdaCallback<Document> results,
853 Find.Builder query) throws MongoDbException;
854
855 /**
856 * Invokes a findAndModify command on the server. The <tt>query</tt> is used
857 * to locate a document to apply a set of <tt>update</tt>s to.
858 *
859 * @param results
860 * Callback for the the found document.
861 * @param command
862 * The details of the find and modify request.
863 * @throws MongoDbException
864 * On an error finding the documents.
865 */
866 public void findAndModifyAsync(Callback<Document> results,
867 FindAndModify command) throws MongoDbException;
868
869 /**
870 * Invokes a findAndModify command on the server. The <tt>query</tt> is used
871 * to locate a document to apply a set of <tt>update</tt>s to.
872 *
873 * @param results
874 * Callback for the the found document.
875 * @param command
876 * The details of the find and modify request.
877 * @throws MongoDbException
878 * On an error finding the documents.
879 */
880 public void findAndModifyAsync(Callback<Document> results,
881 FindAndModify.Builder command) throws MongoDbException;
882
883 /**
884 * Invokes a findAndModify command on the server. The <tt>query</tt> is used
885 * to locate a document to apply a set of <tt>update</tt>s to.
886 *
887 * @param command
888 * The details of the find and modify request.
889 * @return ListenableFuture for the found document.
890 * @throws MongoDbException
891 * On an error finding the documents.
892 */
893 public ListenableFuture<Document> findAndModifyAsync(FindAndModify command)
894 throws MongoDbException;
895
896 /**
897 * Invokes a findAndModify command on the server. The <tt>query</tt> is used
898 * to locate a document to apply a set of <tt>update</tt>s to.
899 *
900 * @param command
901 * The details of the find and modify request.
902 * @return ListenableFuture for the found document.
903 * @throws MongoDbException
904 * On an error finding the documents.
905 */
906 public ListenableFuture<Document> findAndModifyAsync(
907 FindAndModify.Builder command) throws MongoDbException;
908
909 /**
910 * Invokes a findAndModify command on the server. The <tt>query</tt> is used
911 * to locate a document to apply a set of <tt>update</tt>s to.
912 *
913 * @param results
914 * Callback for the the found document.
915 * @param command
916 * The details of the find and modify request.
917 * @throws MongoDbException
918 * On an error finding the documents.
919 */
920 public void findAndModifyAsync(LambdaCallback<Document> results,
921 FindAndModify command) throws MongoDbException;
922
923 /**
924 * Invokes a findAndModify command on the server. The <tt>query</tt> is used
925 * to locate a document to apply a set of <tt>update</tt>s to.
926 *
927 * @param results
928 * Callback for the the found document.
929 * @param command
930 * The details of the find and modify request.
931 * @throws MongoDbException
932 * On an error finding the documents.
933 */
934 public void findAndModifyAsync(LambdaCallback<Document> results,
935 FindAndModify.Builder command) throws MongoDbException;
936
937 /**
938 * Finds the set of documents matching the query document in the collection.
939 *
940 * @param results
941 * Callback that will be notified of the results of the query.
942 * @param query
943 * The query document.
944 * @throws MongoDbException
945 * On an error finding the documents.
946 */
947 public void findAsync(Callback<MongoIterator<Document>> results,
948 DocumentAssignable query) throws MongoDbException;
949
950 /**
951 * Finds the set of documents matching the query in the collection.
952 *
953 * @param results
954 * Callback that will be notified of the results of the query.
955 * @param query
956 * The query details.
957 * @throws MongoDbException
958 * On an error finding the documents.
959 */
960 public void findAsync(Callback<MongoIterator<Document>> results, Find query)
961 throws MongoDbException;
962
963 /**
964 * Finds the set of documents matching the query in the collection.
965 *
966 * @param results
967 * Callback that will be notified of the results of the query.
968 * @param query
969 * The query details.
970 * @throws MongoDbException
971 * On an error finding the documents.
972 */
973 public void findAsync(Callback<MongoIterator<Document>> results,
974 Find.Builder query) throws MongoDbException;
975
976 /**
977 * Finds the set of documents matching the query document in the collection.
978 *
979 * @param query
980 * The query document.
981 * @return A future for the MongoIterator over the documents.
982 * @throws MongoDbException
983 * On an error finding the documents.
984 */
985 public ListenableFuture<MongoIterator<Document>> findAsync(
986 DocumentAssignable query) throws MongoDbException;
987
988 /**
989 * Finds the set of documents matching the query in the collection.
990 *
991 * @param query
992 * The query details.
993 * @return A future for the MongoIterator over the documents.
994 * @throws MongoDbException
995 * On an error finding the documents.
996 */
997 public ListenableFuture<MongoIterator<Document>> findAsync(Find query)
998 throws MongoDbException;
999
1000 /**
1001 * Finds the set of documents matching the query in the collection.
1002 *
1003 * @param query
1004 * The query details.
1005 * @return A future for the MongoIterator over the documents.
1006 * @throws MongoDbException
1007 * On an error finding the documents.
1008 */
1009 public ListenableFuture<MongoIterator<Document>> findAsync(
1010 Find.Builder query) throws MongoDbException;
1011
1012 /**
1013 * Finds the set of documents matching the query document in the collection.
1014 *
1015 * @param results
1016 * Callback that will be notified of the results of the query.
1017 * @param query
1018 * The query document.
1019 * @throws MongoDbException
1020 * On an error finding the documents.
1021 */
1022 public void findAsync(LambdaCallback<MongoIterator<Document>> results,
1023 DocumentAssignable query) throws MongoDbException;
1024
1025 /**
1026 * Finds the set of documents matching the query in the collection.
1027 *
1028 * @param results
1029 * Callback that will be notified of the results of the query.
1030 * @param query
1031 * The query details.
1032 * @throws MongoDbException
1033 * On an error finding the documents.
1034 */
1035 public void findAsync(LambdaCallback<MongoIterator<Document>> results,
1036 Find query) throws MongoDbException;
1037
1038 /**
1039 * Finds the set of documents matching the query in the collection.
1040 *
1041 * @param results
1042 * Callback that will be notified of the results of the query.
1043 * @param query
1044 * The query details.
1045 * @throws MongoDbException
1046 * On an error finding the documents.
1047 */
1048 public void findAsync(LambdaCallback<MongoIterator<Document>> results,
1049 Find.Builder query) throws MongoDbException;
1050
1051 /**
1052 * Finds a single matching document in the collection.
1053 *
1054 * @param results
1055 * Callback that will be notified of the results of the query.
1056 * @param query
1057 * The query document.
1058 * @throws MongoDbException
1059 * On an error finding the document.
1060 */
1061 public void findOneAsync(Callback<Document> results,
1062 DocumentAssignable query) throws MongoDbException;
1063
1064 /**
1065 * Finds a single matching document in the collection.
1066 * <p>
1067 * Note that following options in the {@link Find} class do not make sense
1068 * and are silently ignored by this method.
1069 * <ul>
1070 * <li> {@link Find#getBatchSize() Batch Size} - Automatically set to 1.</li>
1071 * <li> {@link Find#getLimit() Limit} - Automatically set to 1.</li>
1072 * <li> {@link Find#isTailable() Tailable} - This method only returns 1
1073 * document.</li>
1074 * </ul>
1075 * </p>
1076 *
1077 * @param results
1078 * Callback that will be notified of the results of the query.
1079 * @param query
1080 * The query details.
1081 * @throws MongoDbException
1082 * On an error finding the document.
1083 */
1084 public void findOneAsync(Callback<Document> results, Find query)
1085 throws MongoDbException;
1086
1087 /**
1088 * Finds a single matching document in the collection.
1089 * <p>
1090 * Note that following options in the {@link Find} class do not make sense
1091 * and are silently ignored by this method.
1092 * <ul>
1093 * <li> {@link Find#getBatchSize() Batch Size} - Automatically set to 1.</li>
1094 * <li> {@link Find#getLimit() Limit} - Automatically set to 1.</li>
1095 * <li> {@link Find#isTailable() Tailable} - This method only returns 1
1096 * document.</li>
1097 * </ul>
1098 * </p>
1099 *
1100 * @param results
1101 * Callback that will be notified of the results of the query.
1102 * @param query
1103 * The query details.
1104 * @throws MongoDbException
1105 * On an error finding the document.
1106 */
1107 public void findOneAsync(Callback<Document> results, Find.Builder query)
1108 throws MongoDbException;
1109
1110 /**
1111 * Finds a single matching document in the collection.
1112 *
1113 * @param query
1114 * The query document.
1115 * @return The first found document.
1116 * @throws MongoDbException
1117 * On an error finding the document.
1118 */
1119 public ListenableFuture<Document> findOneAsync(DocumentAssignable query)
1120 throws MongoDbException;
1121
1122 /**
1123 * Finds a single matching document in the collection.
1124 * <p>
1125 * Note that following options in the {@link Find} class do not make sense
1126 * and are silently ignored by this method.
1127 * <ul>
1128 * <li> {@link Find#getBatchSize() Batch Size} - Automatically set to 1.</li>
1129 * <li> {@link Find#getLimit() Limit} - Automatically set to 1.</li>
1130 * <li> {@link Find#isTailable() Tailable} - This method only returns 1
1131 * document.</li>
1132 * </ul>
1133 * </p>
1134 *
1135 * @param query
1136 * The query details.
1137 * @return The first found document.
1138 * @throws MongoDbException
1139 * On an error finding the document.
1140 */
1141 public ListenableFuture<Document> findOneAsync(Find query)
1142 throws MongoDbException;
1143
1144 /**
1145 * Finds a single matching document in the collection.
1146 * <p>
1147 * Note that following options in the {@link Find} class do not make sense
1148 * and are silently ignored by this method.
1149 * <ul>
1150 * <li> {@link Find#getBatchSize() Batch Size} - Automatically set to 1.</li>
1151 * <li> {@link Find#getLimit() Limit} - Automatically set to 1.</li>
1152 * <li> {@link Find#isTailable() Tailable} - This method only returns 1
1153 * document.</li>
1154 * </ul>
1155 * </p>
1156 *
1157 * @param query
1158 * The query details.
1159 * @return The first found document.
1160 * @throws MongoDbException
1161 * On an error finding the document.
1162 */
1163 public ListenableFuture<Document> findOneAsync(Find.Builder query)
1164 throws MongoDbException;
1165
1166 /**
1167 * Finds a single matching document in the collection.
1168 *
1169 * @param results
1170 * Callback that will be notified of the results of the query.
1171 * @param query
1172 * The query document.
1173 * @throws MongoDbException
1174 * On an error finding the document.
1175 */
1176 public void findOneAsync(LambdaCallback<Document> results,
1177 DocumentAssignable query) throws MongoDbException;
1178
1179 /**
1180 * Finds a single matching document in the collection.
1181 * <p>
1182 * Note that following options in the {@link Find} class do not make sense
1183 * and are silently ignored by this method.
1184 * <ul>
1185 * <li> {@link Find#getBatchSize() Batch Size} - Automatically set to 1.</li>
1186 * <li> {@link Find#getLimit() Limit} - Automatically set to 1.</li>
1187 * <li> {@link Find#isTailable() Tailable} - This method only returns 1
1188 * document.</li>
1189 * </ul>
1190 * </p>
1191 *
1192 * @param results
1193 * Callback that will be notified of the results of the query.
1194 * @param query
1195 * The query details.
1196 * @throws MongoDbException
1197 * On an error finding the document.
1198 */
1199 public void findOneAsync(LambdaCallback<Document> results, Find query)
1200 throws MongoDbException;
1201
1202 /**
1203 * Finds a single matching document in the collection.
1204 * <p>
1205 * Note that following options in the {@link Find} class do not make sense
1206 * and are silently ignored by this method.
1207 * <ul>
1208 * <li> {@link Find#getBatchSize() Batch Size} - Automatically set to 1.</li>
1209 * <li> {@link Find#getLimit() Limit} - Automatically set to 1.</li>
1210 * <li> {@link Find#isTailable() Tailable} - This method only returns 1
1211 * document.</li>
1212 * </ul>
1213 * </p>
1214 *
1215 * @param results
1216 * Callback that will be notified of the results of the query.
1217 * @param query
1218 * The query details.
1219 * @throws MongoDbException
1220 * On an error finding the document.
1221 */
1222 public void findOneAsync(LambdaCallback<Document> results,
1223 Find.Builder query) throws MongoDbException;
1224
1225 /**
1226 * Invokes a group command on the server.
1227 *
1228 * @param results
1229 * Callback for the group results returned.
1230 * @param command
1231 * The details of the group request.
1232 * @throws MongoDbException
1233 * On an error finding the documents.
1234 */
1235 public void groupByAsync(Callback<MongoIterator<Element>> results,
1236 GroupBy command) throws MongoDbException;
1237
1238 /**
1239 * Invokes a group command on the server.
1240 *
1241 * @param results
1242 * Callback for the group results returned.
1243 * @param command
1244 * The details of the group request.
1245 * @throws MongoDbException
1246 * On an error finding the documents.
1247 */
1248 public void groupByAsync(Callback<MongoIterator<Element>> results,
1249 GroupBy.Builder command) throws MongoDbException;
1250
1251 /**
1252 * Invokes a group command on the server.
1253 *
1254 * @param command
1255 * The details of the group request.
1256 * @return ListenableFuture for the group results returned.
1257 * @throws MongoDbException
1258 * On an error finding the documents.
1259 */
1260 public ListenableFuture<MongoIterator<Element>> groupByAsync(GroupBy command)
1261 throws MongoDbException;
1262
1263 /**
1264 * Invokes a group command on the server.
1265 *
1266 * @param command
1267 * The details of the group request.
1268 * @return ListenableFuture for the group results returned.
1269 * @throws MongoDbException
1270 * On an error finding the documents.
1271 */
1272 public ListenableFuture<MongoIterator<Element>> groupByAsync(
1273 GroupBy.Builder command) throws MongoDbException;
1274
1275 /**
1276 * Invokes a group command on the server.
1277 *
1278 * @param results
1279 * Callback for the group results returned.
1280 * @param command
1281 * The details of the group request.
1282 * @throws MongoDbException
1283 * On an error finding the documents.
1284 */
1285 public void groupByAsync(LambdaCallback<MongoIterator<Element>> results,
1286 GroupBy command) throws MongoDbException;
1287
1288 /**
1289 * Invokes a group command on the server.
1290 *
1291 * @param results
1292 * Callback for the group results returned.
1293 * @param command
1294 * The details of the group request.
1295 * @throws MongoDbException
1296 * On an error finding the documents.
1297 */
1298 public void groupByAsync(LambdaCallback<MongoIterator<Element>> results,
1299 GroupBy.Builder command) throws MongoDbException;
1300
1301 /**
1302 * Inserts a set of documents into the collection.
1303 *
1304 * @param continueOnError
1305 * If the insert should continue if one of the documents causes
1306 * an error.
1307 * @param documents
1308 * The documents to add to the collection.
1309 * @return ListenableFuture that will be updated with the results of the
1310 * insert. Currently, the value is always zero. Once <a
1311 * href="http://jira.mongodb.org/browse/SERVER-4381">SERVER-4381</a>
1312 * is fixed then expected to be the number of documents inserted. If
1313 * the durability is NONE then returns <code>-1</code>.
1314 * @throws MongoDbException
1315 * On an error inserting the documents.
1316 */
1317 public ListenableFuture<Integer> insertAsync(boolean continueOnError,
1318 DocumentAssignable... documents) throws MongoDbException;
1319
1320 /**
1321 * Inserts a set of documents into the collection.
1322 *
1323 * @param continueOnError
1324 * If the insert should continue if one of the documents causes
1325 * an error.
1326 * @param durability
1327 * The durability for the insert.
1328 * @param documents
1329 * The documents to add to the collection.
1330 * @return ListenableFuture that will be updated with the results of the
1331 * insert. Currently, the value is always zero. Once <a
1332 * href="http://jira.mongodb.org/browse/SERVER-4381">SERVER-4381</a>
1333 * is fixed then expected to be the number of documents inserted. If
1334 * the durability is NONE then returns <code>-1</code>.
1335 * @throws MongoDbException
1336 * On an error inserting the documents.
1337 */
1338 public ListenableFuture<Integer> insertAsync(boolean continueOnError,
1339 Durability durability, DocumentAssignable... documents)
1340 throws MongoDbException;
1341
1342 /**
1343 * Inserts a set of documents into the collection.
1344 *
1345 * @param results
1346 * {@link Callback} that will be notified with the results of the
1347 * insert. Currently, the value is always zero. Once <a
1348 * href="http://jira.mongodb.org/browse/SERVER-4381"
1349 * >SERVER-4381</a> is fixed then expected to be the number of
1350 * documents inserted. If the durability is NONE then returns
1351 * <code>-1</code>.
1352 * @param continueOnError
1353 * If the insert should continue if one of the documents causes
1354 * an error.
1355 * @param documents
1356 * The documents to add to the collection.
1357 * @throws MongoDbException
1358 * On an error inserting the documents.
1359 */
1360 public void insertAsync(Callback<Integer> results, boolean continueOnError,
1361 DocumentAssignable... documents) throws MongoDbException;
1362
1363 /**
1364 * Inserts a set of documents into the collection.
1365 *
1366 * @param results
1367 * {@link Callback} that will be notified with the results of the
1368 * insert. Currently, the value is always zero. Once <a
1369 * href="http://jira.mongodb.org/browse/SERVER-4381"
1370 * >SERVER-4381</a> is fixed then expected to be the number of
1371 * documents inserted. If the durability is NONE then returns
1372 * <code>-1</code>.
1373 * @param continueOnError
1374 * If the insert should continue if one of the documents causes
1375 * an error.
1376 * @param durability
1377 * The durability for the insert.
1378 * @param documents
1379 * The documents to add to the collection.
1380 * @throws MongoDbException
1381 * On an error inserting the documents.
1382 */
1383 public void insertAsync(Callback<Integer> results, boolean continueOnError,
1384 Durability durability, DocumentAssignable... documents)
1385 throws MongoDbException;
1386
1387 /**
1388 * Inserts a set of documents into the collection.
1389 *
1390 * @param results
1391 * {@link Callback} that will be notified with the results of the
1392 * insert. Currently, the value is always zero. Once <a
1393 * href="http://jira.mongodb.org/browse/SERVER-4381"
1394 * >SERVER-4381</a> is fixed then expected to be the number of
1395 * documents inserted. If the durability is NONE then returns
1396 * <code>-1</code>.
1397 * @param documents
1398 * The documents to add to the collection.
1399 * @throws MongoDbException
1400 * On an error inserting the documents.
1401 */
1402 public void insertAsync(Callback<Integer> results,
1403 DocumentAssignable... documents) throws MongoDbException;
1404
1405 /**
1406 * Inserts a set of documents into the collection.
1407 *
1408 * @param results
1409 * {@link Callback} that will be notified with the results of the
1410 * insert. Currently, the value is always zero. Once <a
1411 * href="http://jira.mongodb.org/browse/SERVER-4381"
1412 * >SERVER-4381</a> is fixed then expected to be the number of
1413 * documents inserted. If the durability is NONE then returns
1414 * <code>-1</code>.
1415 * @param durability
1416 * The durability for the insert.
1417 * @param documents
1418 * The documents to add to the collection.
1419 * @throws MongoDbException
1420 * On an error inserting the documents.
1421 */
1422 public void insertAsync(Callback<Integer> results, Durability durability,
1423 DocumentAssignable... documents) throws MongoDbException;
1424
1425 /**
1426 * Inserts a set of documents into the collection.
1427 *
1428 * @param documents
1429 * The documents to add to the collection.
1430 * @return ListenableFuture that will be updated with the results of the
1431 * insert. Currently, the value is always zero. Once <a
1432 * href="http://jira.mongodb.org/browse/SERVER-4381">SERVER-4381</a>
1433 * is fixed then expected to be the number of documents inserted. If
1434 * the durability is NONE then returns <code>-1</code>.
1435 * @throws MongoDbException
1436 * On an error inserting the documents.
1437 */
1438 public ListenableFuture<Integer> insertAsync(
1439 DocumentAssignable... documents) throws MongoDbException;
1440
1441 /**
1442 * Inserts a set of documents into the collection.
1443 *
1444 * @param durability
1445 * The durability for the insert.
1446 * @param documents
1447 * The documents to add to the collection.
1448 * @return ListenableFuture that will be updated with the results of the
1449 * insert. Currently, the value is always zero. Once <a
1450 * href="http://jira.mongodb.org/browse/SERVER-4381">SERVER-4381</a>
1451 * is fixed then expected to be the number of documents inserted. If
1452 * the durability is NONE then returns <code>-1</code>.
1453 * @throws MongoDbException
1454 * On an error inserting the documents.
1455 */
1456 public ListenableFuture<Integer> insertAsync(Durability durability,
1457 DocumentAssignable... documents) throws MongoDbException;
1458
1459 /**
1460 * Inserts a set of documents into the collection.
1461 *
1462 * @param results
1463 * {@link Callback} that will be notified with the results of the
1464 * insert. Currently, the value is always zero. Once <a
1465 * href="http://jira.mongodb.org/browse/SERVER-4381"
1466 * >SERVER-4381</a> is fixed then expected to be the number of
1467 * documents inserted. If the durability is NONE then returns
1468 * <code>-1</code>.
1469 * @param continueOnError
1470 * If the insert should continue if one of the documents causes
1471 * an error.
1472 * @param documents
1473 * The documents to add to the collection.
1474 * @throws MongoDbException
1475 * On an error inserting the documents.
1476 */
1477 public void insertAsync(LambdaCallback<Integer> results,
1478 boolean continueOnError, DocumentAssignable... documents)
1479 throws MongoDbException;
1480
1481 /**
1482 * Inserts a set of documents into the collection.
1483 *
1484 * @param results
1485 * {@link Callback} that will be notified with the results of the
1486 * insert. Currently, the value is always zero. Once <a
1487 * href="http://jira.mongodb.org/browse/SERVER-4381"
1488 * >SERVER-4381</a> is fixed then expected to be the number of
1489 * documents inserted. If the durability is NONE then returns
1490 * <code>-1</code>.
1491 * @param continueOnError
1492 * If the insert should continue if one of the documents causes
1493 * an error.
1494 * @param durability
1495 * The durability for the insert.
1496 * @param documents
1497 * The documents to add to the collection.
1498 * @throws MongoDbException
1499 * On an error inserting the documents.
1500 */
1501 public void insertAsync(LambdaCallback<Integer> results,
1502 boolean continueOnError, Durability durability,
1503 DocumentAssignable... documents) throws MongoDbException;
1504
1505 /**
1506 * Inserts a set of documents into the collection.
1507 *
1508 * @param results
1509 * {@link Callback} that will be notified with the results of the
1510 * insert. Currently, the value is always zero. Once <a
1511 * href="http://jira.mongodb.org/browse/SERVER-4381"
1512 * >SERVER-4381</a> is fixed then expected to be the number of
1513 * documents inserted. If the durability is NONE then returns
1514 * <code>-1</code>.
1515 * @param documents
1516 * The documents to add to the collection.
1517 * @throws MongoDbException
1518 * On an error inserting the documents.
1519 */
1520 public void insertAsync(LambdaCallback<Integer> results,
1521 DocumentAssignable... documents) throws MongoDbException;
1522
1523 /**
1524 * Inserts a set of documents into the collection.
1525 *
1526 * @param results
1527 * {@link Callback} that will be notified with the results of the
1528 * insert. Currently, the value is always zero. Once <a
1529 * href="http://jira.mongodb.org/browse/SERVER-4381"
1530 * >SERVER-4381</a> is fixed then expected to be the number of
1531 * documents inserted. If the durability is NONE then returns
1532 * <code>-1</code>.
1533 * @param durability
1534 * The durability for the insert.
1535 * @param documents
1536 * The documents to add to the collection.
1537 * @throws MongoDbException
1538 * On an error inserting the documents.
1539 */
1540 public void insertAsync(LambdaCallback<Integer> results,
1541 Durability durability, DocumentAssignable... documents)
1542 throws MongoDbException;
1543
1544 /**
1545 * Invokes a mapReduce command on the server.
1546 *
1547 * @param results
1548 * Callback for the map/reduce results returned. Note this might
1549 * be empty if the output type is not inline.
1550 * @param command
1551 * The details of the map/reduce request.
1552 * @throws MongoDbException
1553 * On an error finding the documents.
1554 */
1555 public void mapReduceAsync(Callback<MongoIterator<Document>> results,
1556 MapReduce command) throws MongoDbException;
1557
1558 /**
1559 * Invokes a mapReduce command on the server.
1560 *
1561 * @param results
1562 * Callback for the map/reduce results returned. Note this might
1563 * be empty if the output type is not inline.
1564 * @param command
1565 * The details of the map/reduce request.
1566 * @throws MongoDbException
1567 * On an error finding the documents.
1568 */
1569 public void mapReduceAsync(Callback<MongoIterator<Document>> results,
1570 MapReduce.Builder command) throws MongoDbException;
1571
1572 /**
1573 * Invokes a mapReduce command on the server.
1574 *
1575 * @param results
1576 * Callback for the map/reduce results returned. Note this might
1577 * be empty if the output type is not inline.
1578 * @param command
1579 * The details of the map/reduce request.
1580 * @throws MongoDbException
1581 * On an error finding the documents.
1582 */
1583 public void mapReduceAsync(LambdaCallback<MongoIterator<Document>> results,
1584 MapReduce command) throws MongoDbException;
1585
1586 /**
1587 * Invokes a mapReduce command on the server.
1588 *
1589 * @param results
1590 * Callback for the map/reduce results returned. Note this might
1591 * be empty if the output type is not inline.
1592 * @param command
1593 * The details of the map/reduce request.
1594 * @throws MongoDbException
1595 * On an error finding the documents.
1596 */
1597 public void mapReduceAsync(LambdaCallback<MongoIterator<Document>> results,
1598 MapReduce.Builder command) throws MongoDbException;
1599
1600 /**
1601 * Invokes a mapReduce command on the server.
1602 *
1603 * @param command
1604 * The details of the map/reduce request.
1605 * @return ListenableFuture for the map/reduce results returned. Note this
1606 * might be empty if the output type is not inline.
1607 * @throws MongoDbException
1608 * On an error finding the documents.
1609 */
1610 public ListenableFuture<MongoIterator<Document>> mapReduceAsync(
1611 MapReduce command) throws MongoDbException;
1612
1613 /**
1614 * Invokes a mapReduce command on the server.
1615 *
1616 * @param command
1617 * The details of the map/reduce request.
1618 * @return ListenableFuture for the map/reduce results returned. Note this
1619 * might be empty if the output type is not inline.
1620 * @throws MongoDbException
1621 * On an error finding the documents.
1622 */
1623 public ListenableFuture<MongoIterator<Document>> mapReduceAsync(
1624 MapReduce.Builder command) throws MongoDbException;
1625
1626 /**
1627 * Uses the {@code parallelCollectionScan} command to open multiple
1628 * iterators over the collection each configured to scan a distinct regions
1629 * of the collection. You may then use a separate thread to scan each region
1630 * of the collection in parallel.
1631 *
1632 * @param results
1633 * Callback for the collection of iterators.
1634 * @param parallelScan
1635 * The details on the scan.
1636 * @throws MongoDbException
1637 * On an error initializing the parallel scan.
1638 *
1639 * @see <a
1640 * href="http://docs.mongodb.org/manual/reference/command/parallelCollectionScan/">parallelCollectionScan
1641 * Command</a>
1642 */
1643 public void parallelScanAsync(
1644 Callback<Collection<MongoIterator<Document>>> results,
1645 ParallelScan parallelScan) throws MongoDbException;
1646
1647 /**
1648 * Uses the {@code parallelCollectionScan} command to open multiple
1649 * iterators over the collection each configured to scan a distinct regions
1650 * of the collection. You may then use a separate thread to scan each region
1651 * of the collection in parallel.
1652 *
1653 * @param results
1654 * Callback for the collection of iterators.
1655 * @param parallelScan
1656 * The details on the scan.
1657 * @throws MongoDbException
1658 * On an error initializing the parallel scan.
1659 *
1660 * @see <a
1661 * href="http://docs.mongodb.org/manual/reference/command/parallelCollectionScan/">parallelCollectionScan
1662 * Command</a>
1663 */
1664 public void parallelScanAsync(
1665 Callback<Collection<MongoIterator<Document>>> results,
1666 ParallelScan.Builder parallelScan) throws MongoDbException;
1667
1668 /**
1669 * Uses the {@code parallelCollectionScan} command to open multiple
1670 * iterators over the collection each configured to scan a distinct regions
1671 * of the collection. You may then use a separate thread to scan each region
1672 * of the collection in parallel.
1673 *
1674 * @param results
1675 * Callback for the collection of iterators.
1676 * @param parallelScan
1677 * The details on the scan.
1678 * @throws MongoDbException
1679 * On an error initializing the parallel scan.
1680 *
1681 * @see <a
1682 * href="http://docs.mongodb.org/manual/reference/command/parallelCollectionScan/">parallelCollectionScan
1683 * Command</a>
1684 */
1685 public void parallelScanAsync(
1686 LambdaCallback<Collection<MongoIterator<Document>>> results,
1687 ParallelScan parallelScan) throws MongoDbException;
1688
1689 /**
1690 * Uses the {@code parallelCollectionScan} command to open multiple
1691 * iterators over the collection each configured to scan a distinct regions
1692 * of the collection. You may then use a separate thread to scan each region
1693 * of the collection in parallel.
1694 *
1695 * @param results
1696 * Callback for the collection of iterators.
1697 * @param parallelScan
1698 * The details on the scan.
1699 * @throws MongoDbException
1700 * On an error initializing the parallel scan.
1701 *
1702 * @see <a
1703 * href="http://docs.mongodb.org/manual/reference/command/parallelCollectionScan/">parallelCollectionScan
1704 * Command</a>
1705 */
1706 public void parallelScanAsync(
1707 LambdaCallback<Collection<MongoIterator<Document>>> results,
1708 ParallelScan.Builder parallelScan) throws MongoDbException;
1709
1710 /**
1711 * Uses the {@code parallelCollectionScan} command to open multiple
1712 * iterators over the collection each configured to scan a distinct regions
1713 * of the collection. You may then use a separate thread to scan each region
1714 * of the collection in parallel.
1715 *
1716 * @param parallelScan
1717 * The details on the scan.
1718 * @return The collection of iterators.
1719 * @throws MongoDbException
1720 * On an error initializing the parallel scan.
1721 *
1722 * @see <a
1723 * href="http://docs.mongodb.org/manual/reference/command/parallelCollectionScan/">parallelCollectionScan
1724 * Command</a>
1725 */
1726 public ListenableFuture<Collection<MongoIterator<Document>>> parallelScanAsync(
1727 ParallelScan parallelScan) throws MongoDbException;
1728
1729 /**
1730 * Uses the {@code parallelCollectionScan} command to open multiple
1731 * iterators over the collection each configured to scan a distinct regions
1732 * of the collection. You may then use a separate thread to scan each region
1733 * of the collection in parallel.
1734 *
1735 * @param parallelScan
1736 * The details on the scan.
1737 * @return The collection of iterators.
1738 * @throws MongoDbException
1739 * On an error initializing the parallel scan.
1740 *
1741 * @see <a
1742 * href="http://docs.mongodb.org/manual/reference/command/parallelCollectionScan/">parallelCollectionScan
1743 * Command</a>
1744 */
1745 public ListenableFuture<Collection<MongoIterator<Document>>> parallelScanAsync(
1746 ParallelScan.Builder parallelScan) throws MongoDbException;
1747
1748 /**
1749 * Saves the {@code document} to the collection.
1750 * <p>
1751 * If the {@code document} does not contain an {@code _id} field then this
1752 * method is equivalent to:
1753 * {@link #insertAsync(Callback,DocumentAssignable...) insertAsync(results,
1754 * document)}.
1755 * </p>
1756 * <p>
1757 * If the {@code document} does contain an {@code _id} field then this
1758 * method is equivalent to:
1759 * {@link #updateAsync(Callback,DocumentAssignable, DocumentAssignable, boolean, boolean)
1760 * updateAsync(results, BuilderFactory.start().add(document.get("_id")),
1761 * document, false, true)}.
1762 * </p>
1763 *
1764 * @param results
1765 * {@link Callback} that will be notified with the results of the
1766 * insert. If the durability of the operation is NONE then this
1767 * will be -1.
1768 * @param document
1769 * The document to save to the collection.
1770 * @throws MongoDbException
1771 * On an error saving the documents.
1772 */
1773 public void saveAsync(Callback<Integer> results, DocumentAssignable document)
1774 throws MongoDbException;
1775
1776 /**
1777 * Saves the {@code document} to the collection.
1778 * <p>
1779 * If the {@code document} does not contain an {@code _id} field then this
1780 * method is equivalent to:
1781 * {@link #insertAsync(Callback, Durability, DocumentAssignable...)
1782 * insertAsync(results, durability, document)}.
1783 * </p>
1784 * <p>
1785 * If the {@code document} does contain an {@code _id} field then this
1786 * method is equivalent to:
1787 * {@link #updateAsync(Callback,DocumentAssignable, DocumentAssignable, boolean, boolean, Durability)
1788 * updateAsync(results, BuilderFactory.start().add(document.get("_id")),
1789 * document, false, true, durability)}.
1790 * </p>
1791 *
1792 * @param results
1793 * {@link Callback} that will be notified with the results of the
1794 * insert. If the durability of the operation is NONE then this
1795 * will be -1.
1796 * @param document
1797 * The document to save to the collection.
1798 * @param durability
1799 * The durability for the save.
1800 * @throws MongoDbException
1801 * On an error saving the documents.
1802 */
1803 public void saveAsync(Callback<Integer> results,
1804 DocumentAssignable document, Durability durability)
1805 throws MongoDbException;
1806
1807 /**
1808 * Saves the {@code document} to the collection.
1809 * <p>
1810 * If the {@code document} does not contain an {@code _id} field then this
1811 * method is equivalent to: {@link #insertAsync(DocumentAssignable...)
1812 * insertAsync(document)}.
1813 * </p>
1814 * <p>
1815 * If the {@code document} does contain an {@code _id} field then this
1816 * method is equivalent to:
1817 * {@link #updateAsync(DocumentAssignable, DocumentAssignable, boolean, boolean)
1818 * updateAsync(BuilderFactory.start().add(document.get("_id")), document,
1819 * false, true)}.
1820 * </p>
1821 *
1822 * @param document
1823 * The document to save to the collection.
1824 * @return ListenableFuture that will be updated with the results of the
1825 * save. If the durability of the operation is NONE then this will
1826 * be -1.
1827 * @throws MongoDbException
1828 * On an error saving the documents.
1829 */
1830 public ListenableFuture<Integer> saveAsync(DocumentAssignable document)
1831 throws MongoDbException;
1832
1833 /**
1834 * Saves the {@code document} to the collection.
1835 * <p>
1836 * If the {@code document} does not contain an {@code _id} field then this
1837 * method is equivalent to:
1838 * {@link #insertAsync(Durability, DocumentAssignable...)
1839 * insertAsync(durability, document)}.
1840 * </p>
1841 * <p>
1842 * If the {@code document} does contain an {@code _id} field then this
1843 * method is equivalent to:
1844 * {@link #updateAsync(DocumentAssignable, DocumentAssignable, boolean, boolean, Durability)
1845 * updateAsync(BuilderFactory.start().add(document.get("_id")), document,
1846 * false, true, durability)}.
1847 * </p>
1848 *
1849 * @param document
1850 * The document to save to the collection.
1851 * @param durability
1852 * The durability for the save.
1853 * @return ListenableFuture that will be updated with the results of the
1854 * save. If the durability of the operation is NONE then this will
1855 * be -1.
1856 * @throws MongoDbException
1857 * On an error saving the documents.
1858 */
1859 public ListenableFuture<Integer> saveAsync(DocumentAssignable document,
1860 Durability durability) throws MongoDbException;
1861
1862 /**
1863 * Saves the {@code document} to the collection.
1864 * <p>
1865 * If the {@code document} does not contain an {@code _id} field then this
1866 * method is equivalent to:
1867 * {@link #insertAsync(Callback,DocumentAssignable...) insertAsync(results,
1868 * document)}.
1869 * </p>
1870 * <p>
1871 * If the {@code document} does contain an {@code _id} field then this
1872 * method is equivalent to:
1873 * {@link #updateAsync(Callback,DocumentAssignable, DocumentAssignable, boolean, boolean)
1874 * updateAsync(results, BuilderFactory.start().add(document.get("_id")),
1875 * document, false, true)}.
1876 * </p>
1877 *
1878 * @param results
1879 * {@link Callback} that will be notified with the results of the
1880 * insert. If the durability of the operation is NONE then this
1881 * will be -1.
1882 * @param document
1883 * The document to save to the collection.
1884 * @throws MongoDbException
1885 * On an error saving the documents.
1886 */
1887 public void saveAsync(LambdaCallback<Integer> results,
1888 DocumentAssignable document) throws MongoDbException;
1889
1890 /**
1891 * Saves the {@code document} to the collection.
1892 * <p>
1893 * If the {@code document} does not contain an {@code _id} field then this
1894 * method is equivalent to:
1895 * {@link #insertAsync(Callback, Durability, DocumentAssignable...)
1896 * insertAsync(results, durability, document)}.
1897 * </p>
1898 * <p>
1899 * If the {@code document} does contain an {@code _id} field then this
1900 * method is equivalent to:
1901 * {@link #updateAsync(Callback,DocumentAssignable, DocumentAssignable, boolean, boolean, Durability)
1902 * updateAsync(results, BuilderFactory.start().add(document.get("_id")),
1903 * document, false, true, durability)}.
1904 * </p>
1905 *
1906 * @param results
1907 * {@link Callback} that will be notified with the results of the
1908 * insert. If the durability of the operation is NONE then this
1909 * will be -1.
1910 * @param document
1911 * The document to save to the collection.
1912 * @param durability
1913 * The durability for the save.
1914 * @throws MongoDbException
1915 * On an error saving the documents.
1916 */
1917 public void saveAsync(LambdaCallback<Integer> results,
1918 DocumentAssignable document, Durability durability)
1919 throws MongoDbException;
1920
1921 /**
1922 * Performs an aggregation and streams them to the provided callback one at
1923 * a time.
1924 * <p>
1925 * The sequence of callbacks will be terminated by either calling the
1926 * {@link LambdaCallback#accept(Throwable, Object) results.accept(...)}
1927 * method with <code>null</code> for both parameters or by calling the
1928 * method with an error for the first parameter.
1929 * </p>
1930 * <p>
1931 * Applications can terminate the stream by throwing a
1932 * {@link RuntimeException} from the {@link StreamCallback#callback} method
1933 * (which will then call the {@link StreamCallback#exception} method or by
1934 * closing the {@link MongoCursorControl} returned from this method.
1935 * </p>
1936 * <p>
1937 * Only a single thread will invoke the callback at a time but that thread
1938 * may change over time.
1939 * </p>
1940 * <p>
1941 * If the callback processing requires any significant time (including I/O)
1942 * it is recommended that an
1943 * {@link MongoClientConfiguration#setExecutor(java.util.concurrent.Executor)
1944 * Executor} be configured within the {@link MongoClientConfiguration} to
1945 * off-load the processing from the receive thread.
1946 * </p>
1947 *
1948 * @param results
1949 * Callback that will be notified of the results of the query.
1950 * @param aggregation
1951 * The aggregation details.
1952 * @return A {@link MongoCursorControl} to control the cursor streaming
1953 * documents to the caller. This includes the ability to stop the
1954 * cursor and persist its state.
1955 * @throws MongoDbException
1956 * On an error finding the documents.
1957 */
1958 public MongoCursorControl stream(LambdaCallback<Document> results,
1959 Aggregate aggregation) throws MongoDbException;
1960
1961 /**
1962 * Performs an aggregation and streams them to the provided callback one at
1963 * a time.
1964 * <p>
1965 * The sequence of callbacks will be terminated by either calling the
1966 * {@link LambdaCallback#accept(Throwable, Object) results.accept(...)}
1967 * method with <code>null</code> for both parameters or by calling the
1968 * method with an error for the first parameter.
1969 * </p>
1970 * <p>
1971 * Applications can terminate the stream by throwing a
1972 * {@link RuntimeException} from the {@link StreamCallback#callback} method
1973 * (which will then call the {@link StreamCallback#exception} method or by
1974 * closing the {@link MongoCursorControl} returned from this method.
1975 * </p>
1976 * <p>
1977 * Only a single thread will invoke the callback at a time but that thread
1978 * may change over time.
1979 * </p>
1980 * <p>
1981 * If the callback processing requires any significant time (including I/O)
1982 * it is recommended that an
1983 * {@link MongoClientConfiguration#setExecutor(java.util.concurrent.Executor)
1984 * Executor} be configured within the {@link MongoClientConfiguration} to
1985 * off-load the processing from the receive thread.
1986 * </p>
1987 * <p>
1988 * This method is equivalent to {@link #stream(StreamCallback, Aggregate)
1989 * stream( results, aggregation.build() ) }.
1990 * </p>
1991 *
1992 * @param results
1993 * Callback that will be notified of the results of the query.
1994 * @param aggregation
1995 * The aggregation details.
1996 * @return A {@link MongoCursorControl} to control the cursor streaming
1997 * documents to the caller. This includes the ability to stop the
1998 * cursor and persist its state.
1999 * @throws MongoDbException
2000 * On an error finding the documents.
2001 */
2002 public MongoCursorControl stream(LambdaCallback<Document> results,
2003 Aggregate.Builder aggregation) throws MongoDbException;
2004
2005 /**
2006 * Finds the set of documents matching the query in the collection and
2007 * streams them to the provided callback one at a time.
2008 * <p>
2009 * The sequence of callbacks will be terminated by either calling the
2010 * {@link LambdaCallback#accept(Throwable, Object) results.accept(...)}
2011 * method with <code>null</code> for both parameters or by calling the
2012 * method with an error for the first parameter.
2013 * </p>
2014 * <p>
2015 * Applications can terminate the stream by throwing a
2016 * {@link RuntimeException} from the {@link StreamCallback#callback} method
2017 * (which will then call the {@link StreamCallback#exception} method or by
2018 * closing the {@link MongoCursorControl} returned from this method.
2019 * </p>
2020 * <p>
2021 * Only a single thread will invoke the callback at a time but that thread
2022 * may change over time.
2023 * </p>
2024 * <p>
2025 * If the callback processing requires any significant time (including I/O)
2026 * it is recommended that an
2027 * {@link MongoClientConfiguration#setExecutor(java.util.concurrent.Executor)
2028 * Executor} be configured within the {@link MongoClientConfiguration} to
2029 * off-load the processing from the receive thread.
2030 * </p>
2031 *
2032 * @param results
2033 * Callback that will be notified of the results of the query.
2034 * @param query
2035 * The query details.
2036 * @return A {@link MongoCursorControl} to control the cursor streaming
2037 * documents to the caller. This includes the ability to stop the
2038 * cursor and persist its state.
2039 * @throws MongoDbException
2040 * On an error finding the documents.
2041 */
2042 public MongoCursorControl stream(LambdaCallback<Document> results,
2043 Find query) throws MongoDbException;
2044
2045 /**
2046 * Finds the set of documents matching the query in the collection and
2047 * streams them to the provided callback one at a time.
2048 * <p>
2049 * The sequence of callbacks will be terminated by either calling the
2050 * {@link LambdaCallback#accept(Throwable, Object) results.accept(...)}
2051 * method with <code>null</code> for both parameters or by calling the
2052 * method with an error for the first parameter.
2053 * </p>
2054 * <p>
2055 * Applications can terminate the stream by throwing a
2056 * {@link RuntimeException} from the {@link StreamCallback#callback} method
2057 * (which will then call the {@link StreamCallback#exception} method or by
2058 * closing the {@link MongoCursorControl} returned from this method.
2059 * </p>
2060 * <p>
2061 * Only a single thread will invoke the callback at a time but that thread
2062 * may change over time.
2063 * </p>
2064 * <p>
2065 * If the callback processing requires any significant time (including I/O)
2066 * it is recommended that an
2067 * {@link MongoClientConfiguration#setExecutor(java.util.concurrent.Executor)
2068 * Executor} be configured within the {@link MongoClientConfiguration} to
2069 * off-load the processing from the receive thread.
2070 * </p>
2071 *
2072 * @param results
2073 * Callback that will be notified of the results of the query.
2074 * @param query
2075 * The query details.
2076 * @return A {@link MongoCursorControl} to control the cursor streaming
2077 * documents to the caller. This includes the ability to stop the
2078 * cursor and persist its state.
2079 * @throws MongoDbException
2080 * On an error finding the documents.
2081 */
2082 public MongoCursorControl stream(LambdaCallback<Document> results,
2083 Find.Builder query) throws MongoDbException;
2084
2085 /**
2086 * Performs an aggregation and streams them to the provided callback one at
2087 * a time.
2088 * <p>
2089 * The sequence of callbacks will be terminated by either calling the
2090 * {@link StreamCallback#done() results.done()} method or by calling the
2091 * {@link StreamCallback#exception(Throwable) results.exception(...)} method
2092 * (in the event of an error).
2093 * </p>
2094 * <p>
2095 * Applications can terminate the stream by throwing a
2096 * {@link RuntimeException} from the {@link StreamCallback#callback} method
2097 * (which will then call the {@link StreamCallback#exception} method or by
2098 * closing the {@link MongoCursorControl} returned from this method.
2099 * </p>
2100 * <p>
2101 * Only a single thread will invoke the callback at a time but that thread
2102 * may change over time.
2103 * </p>
2104 * <p>
2105 * If the callback processing requires any significant time (including I/O)
2106 * it is recommended that an
2107 * {@link MongoClientConfiguration#setExecutor(java.util.concurrent.Executor)
2108 * Executor} be configured within the {@link MongoClientConfiguration} to
2109 * off-load the processing from the receive thread.
2110 * </p>
2111 *
2112 * @param results
2113 * Callback that will be notified of the results of the query.
2114 * @param aggregation
2115 * The aggregation details.
2116 * @return A {@link MongoCursorControl} to control the cursor streaming
2117 * documents to the caller. This includes the ability to stop the
2118 * cursor and persist its state.
2119 * @throws MongoDbException
2120 * On an error finding the documents.
2121 */
2122 public MongoCursorControl stream(StreamCallback<Document> results,
2123 Aggregate aggregation) throws MongoDbException;
2124
2125 /**
2126 * Performs an aggregation and streams them to the provided callback one at
2127 * a time.
2128 * <p>
2129 * The sequence of callbacks will be terminated by either calling the
2130 * {@link StreamCallback#done() results.done()} method or by calling the
2131 * {@link StreamCallback#exception(Throwable) results.exception(...)} method
2132 * (in the event of an error).
2133 * </p>
2134 * <p>
2135 * Applications can terminate the stream by throwing a
2136 * {@link RuntimeException} from the {@link StreamCallback#callback} method
2137 * (which will then call the {@link StreamCallback#exception} method or by
2138 * closing the {@link MongoCursorControl} returned from this method.
2139 * </p>
2140 * <p>
2141 * Only a single thread will invoke the callback at a time but that thread
2142 * may change over time.
2143 * </p>
2144 * <p>
2145 * If the callback processing requires any significant time (including I/O)
2146 * it is recommended that an
2147 * {@link MongoClientConfiguration#setExecutor(java.util.concurrent.Executor)
2148 * Executor} be configured within the {@link MongoClientConfiguration} to
2149 * off-load the processing from the receive thread.
2150 * </p>
2151 * <p>
2152 * This method is equivalent to {@link #stream(StreamCallback, Aggregate)
2153 * stream( results, aggregation.build() ) }.
2154 * </p>
2155 *
2156 * @param results
2157 * Callback that will be notified of the results of the query.
2158 * @param aggregation
2159 * The aggregation details.
2160 * @return A {@link MongoCursorControl} to control the cursor streaming
2161 * documents to the caller. This includes the ability to stop the
2162 * cursor and persist its state.
2163 * @throws MongoDbException
2164 * On an error finding the documents.
2165 */
2166 public MongoCursorControl stream(StreamCallback<Document> results,
2167 Aggregate.Builder aggregation) throws MongoDbException;
2168
2169 /**
2170 * Finds the set of documents matching the query in the collection and
2171 * streams them to the provided callback one at a time.
2172 * <p>
2173 * The sequence of callbacks will be terminated by either calling the
2174 * {@link StreamCallback#done() results.done()} method or by calling the
2175 * {@link StreamCallback#exception(Throwable) results.exception(...)} method
2176 * (in the event of an error).
2177 * </p>
2178 * <p>
2179 * Applications can terminate the stream by throwing a
2180 * {@link RuntimeException} from the {@link StreamCallback#callback} method
2181 * (which will then call the {@link StreamCallback#exception} method or by
2182 * closing the {@link MongoCursorControl} returned from this method.
2183 * </p>
2184 * <p>
2185 * Only a single thread will invoke the callback at a time but that thread
2186 * may change over time.
2187 * </p>
2188 * <p>
2189 * If the callback processing requires any significant time (including I/O)
2190 * it is recommended that an
2191 * {@link MongoClientConfiguration#setExecutor(java.util.concurrent.Executor)
2192 * Executor} be configured within the {@link MongoClientConfiguration} to
2193 * off-load the processing from the receive thread.
2194 * </p>
2195 *
2196 * @param results
2197 * Callback that will be notified of the results of the query.
2198 * @param query
2199 * The query details.
2200 * @return A {@link MongoCursorControl} to control the cursor streaming
2201 * documents to the caller. This includes the ability to stop the
2202 * cursor and persist its state.
2203 * @throws MongoDbException
2204 * On an error finding the documents.
2205 */
2206 public MongoCursorControl stream(StreamCallback<Document> results,
2207 Find query) throws MongoDbException;
2208
2209 /**
2210 * Finds the set of documents matching the query in the collection and
2211 * streams them to the provided callback one at a time.
2212 * <p>
2213 * The sequence of callbacks will be terminated by either calling the
2214 * {@link StreamCallback#done() results.done()} method or by calling the
2215 * {@link StreamCallback#exception(Throwable) results.exception(...)} method
2216 * (in the event of an error).
2217 * </p>
2218 * <p>
2219 * Applications can terminate the stream by throwing a
2220 * {@link RuntimeException} from the {@link StreamCallback#callback} method
2221 * (which will then call the {@link StreamCallback#exception} method or by
2222 * closing the {@link MongoCursorControl} returned from this method.
2223 * </p>
2224 * <p>
2225 * Only a single thread will invoke the callback at a time but that thread
2226 * may change over time.
2227 * </p>
2228 * <p>
2229 * If the callback processing requires any significant time (including I/O)
2230 * it is recommended that an
2231 * {@link MongoClientConfiguration#setExecutor(java.util.concurrent.Executor)
2232 * Executor} be configured within the {@link MongoClientConfiguration} to
2233 * off-load the processing from the receive thread.
2234 * </p>
2235 *
2236 * @param results
2237 * Callback that will be notified of the results of the query.
2238 * @param query
2239 * The query details.
2240 * @return A {@link MongoCursorControl} to control the cursor streaming
2241 * documents to the caller. This includes the ability to stop the
2242 * cursor and persist its state.
2243 * @throws MongoDbException
2244 * On an error finding the documents.
2245 */
2246 public MongoCursorControl stream(StreamCallback<Document> results,
2247 Find.Builder query) throws MongoDbException;
2248
2249 /**
2250 * Finds the set of documents matching the query document in the collection
2251 * and streams them to the provided callback one at a time.
2252 * <p>
2253 * The sequence of callbacks will be terminated by either calling the
2254 * {@link Callback#callback(Object) results.callback(...)} method with
2255 * <code>null</code> or by calling the {@link Callback#exception(Throwable)
2256 * results.exception(...)} method on an error.
2257 * </p>
2258 * <p>
2259 * Applications can terminate the stream by throwing a
2260 * {@link RuntimeException} from the {@link Callback#callback} method (which
2261 * will then call the {@link Callback#exception} method).
2262 * </p>
2263 * <p>
2264 * Only a single thread will invoke the callback at a time but that thread
2265 * may change over time.
2266 * </p>
2267 * <p>
2268 * If the callback processing requires any significant time (including I/O)
2269 * it is recommended that an
2270 * {@link MongoClientConfiguration#setExecutor(java.util.concurrent.Executor)
2271 * Executor} be configured within the {@link MongoClientConfiguration} to
2272 * off-load the processing from the receive thread.
2273 * </p>
2274 *
2275 * @param results
2276 * Callback that will be notified of the results of the query.
2277 * @param query
2278 * The query document.
2279 * @return A {@link MongoCursorControl} to control the cursor streaming
2280 * documents to the caller. This includes the ability to stop the
2281 * cursor and persist its state.
2282 * @throws MongoDbException
2283 * On an error finding the documents.
2284 * @deprecated Use the
2285 * {@link #streamingFind(StreamCallback, DocumentAssignable)}
2286 * method instead. This method will be removed after the 1.3.0
2287 * release.
2288 */
2289 @Deprecated
2290 public MongoCursorControl streamingFind(Callback<Document> results,
2291 DocumentAssignable query) throws MongoDbException;
2292
2293 /**
2294 * Finds the set of documents matching the query in the collection and
2295 * streams them to the provided callback one at a time.
2296 * <p>
2297 * The sequence of callbacks will be terminated by either calling the
2298 * {@link Callback#callback(Object) results.callback(...)} method with
2299 * <code>null</code> or by calling the {@link Callback#exception(Throwable)
2300 * results.exception(...)} method on an error.
2301 * </p>
2302 * <p>
2303 * Applications can terminate the stream by throwing a
2304 * {@link RuntimeException} from the {@link Callback#callback} method (which
2305 * will then call the {@link Callback#exception} method).
2306 * </p>
2307 * <p>
2308 * Only a single thread will invoke the callback at a time but that thread
2309 * may change over time.
2310 * </p>
2311 * <p>
2312 * If the callback processing requires any significant time (including I/O)
2313 * it is recommended that an
2314 * {@link MongoClientConfiguration#setExecutor(java.util.concurrent.Executor)
2315 * Executor} be configured within the {@link MongoClientConfiguration} to
2316 * off-load the processing from the receive thread.
2317 * </p>
2318 *
2319 * @param results
2320 * Callback that will be notified of the results of the query.
2321 * @param query
2322 * The query details.
2323 * @return A {@link MongoCursorControl} to control the cursor streaming
2324 * documents to the caller. This includes the ability to stop the
2325 * cursor and persist its state.
2326 * @throws MongoDbException
2327 * On an error finding the documents.
2328 * @deprecated Use the {@link #stream(StreamCallback, Find)} method instead.
2329 * This method will be removed after the 1.3.0 release.
2330 */
2331 @Deprecated
2332 public MongoCursorControl streamingFind(Callback<Document> results,
2333 Find query) throws MongoDbException;
2334
2335 /**
2336 * Finds the set of documents matching the query document in the collection
2337 * and streams them to the provided callback one at a time.
2338 * <p>
2339 * The sequence of callbacks will be terminated by either calling the
2340 * {@link LambdaCallback#accept(Throwable, Object) results.accept(...)}
2341 * method with <code>null</code> for both parameters or by calling the
2342 * method with an error for the first parameter.
2343 * </p>
2344 * <p>
2345 * Applications can terminate the stream by throwing a
2346 * {@link RuntimeException} from the {@link StreamCallback#callback} method
2347 * (which will then call the {@link StreamCallback#exception} method or by
2348 * closing the {@link MongoCursorControl} returned from this method.
2349 * </p>
2350 * <p>
2351 * Only a single thread will invoke the callback at a time but that thread
2352 * may change over time.
2353 * </p>
2354 * <p>
2355 * If the callback processing requires any significant time (including I/O)
2356 * it is recommended that an
2357 * {@link MongoClientConfiguration#setExecutor(java.util.concurrent.Executor)
2358 * Executor} be configured within the {@link MongoClientConfiguration} to
2359 * off-load the processing from the receive thread.
2360 * </p>
2361 *
2362 * @param results
2363 * Callback that will be notified of the results of the query.
2364 * @param query
2365 * The query document.
2366 * @return A {@link MongoCursorControl} to control the cursor streaming
2367 * documents to the caller. This includes the ability to stop the
2368 * cursor and persist its state.
2369 * @throws MongoDbException
2370 * On an error finding the documents.
2371 */
2372 public MongoCursorControl streamingFind(LambdaCallback<Document> results,
2373 DocumentAssignable query) throws MongoDbException;
2374
2375 /**
2376 * Finds the set of documents matching the query document in the collection
2377 * and streams them to the provided callback one at a time.
2378 * <p>
2379 * The sequence of callbacks will be terminated by either calling the
2380 * {@link StreamCallback#done() results.done()} method or by calling the
2381 * {@link StreamCallback#exception(Throwable) results.exception(...)} method
2382 * (in the event of an error).
2383 * </p>
2384 * <p>
2385 * Applications can terminate the stream by throwing a
2386 * {@link RuntimeException} from the {@link StreamCallback#callback} method
2387 * (which will then call the {@link StreamCallback#exception} method or by
2388 * closing the {@link MongoCursorControl} returned from this method.
2389 * </p>
2390 * <p>
2391 * Only a single thread will invoke the callback at a time but that thread
2392 * may change over time.
2393 * </p>
2394 * <p>
2395 * If the callback processing requires any significant time (including I/O)
2396 * it is recommended that an
2397 * {@link MongoClientConfiguration#setExecutor(java.util.concurrent.Executor)
2398 * Executor} be configured within the {@link MongoClientConfiguration} to
2399 * off-load the processing from the receive thread.
2400 * </p>
2401 *
2402 * @param results
2403 * Callback that will be notified of the results of the query.
2404 * @param query
2405 * The query document.
2406 * @return A {@link MongoCursorControl} to control the cursor streaming
2407 * documents to the caller. This includes the ability to stop the
2408 * cursor and persist its state.
2409 * @throws MongoDbException
2410 * On an error finding the documents.
2411 */
2412 public MongoCursorControl streamingFind(StreamCallback<Document> results,
2413 DocumentAssignable query) throws MongoDbException;
2414
2415 /**
2416 * Finds the set of documents matching the query in the collection and
2417 * streams them to the provided callback one at a time.
2418 * <p>
2419 * The sequence of callbacks will be terminated by either calling the
2420 * {@link StreamCallback#done() results.done()} method or by calling the
2421 * {@link StreamCallback#exception(Throwable) results.exception(...)} method
2422 * (in the event of an error).
2423 * </p>
2424 * <p>
2425 * Applications can terminate the stream by throwing a
2426 * {@link RuntimeException} from the {@link StreamCallback#callback} method
2427 * (which will then call the {@link StreamCallback#exception} method or by
2428 * closing the {@link MongoCursorControl} returned from this method.
2429 * </p>
2430 * <p>
2431 * Only a single thread will invoke the callback at a time but that thread
2432 * may change over time.
2433 * </p>
2434 * <p>
2435 * If the callback processing requires any significant time (including I/O)
2436 * it is recommended that an
2437 * {@link MongoClientConfiguration#setExecutor(java.util.concurrent.Executor)
2438 * Executor} be configured within the {@link MongoClientConfiguration} to
2439 * off-load the processing from the receive thread.
2440 * </p>
2441 *
2442 * @param results
2443 * Callback that will be notified of the results of the query.
2444 * @param query
2445 * The query details.
2446 * @return A {@link MongoCursorControl} to control the cursor streaming
2447 * documents to the caller. This includes the ability to stop the
2448 * cursor and persist its state.
2449 * @throws MongoDbException
2450 * On an error finding the documents.
2451 * @deprecated Use the {@link #stream(StreamCallback, Find)} method instead.
2452 * This method will be removed after the 1.4.0 release.
2453 */
2454 @Deprecated
2455 public MongoCursorControl streamingFind(StreamCallback<Document> results,
2456 Find query) throws MongoDbException;
2457
2458 /**
2459 * Finds the set of documents matching the query in the collection and
2460 * streams them to the provided callback one at a time.
2461 * <p>
2462 * The sequence of callbacks will be terminated by either calling the
2463 * {@link StreamCallback#done() results.done()} method or by calling the
2464 * {@link StreamCallback#exception(Throwable) results.exception(...)} method
2465 * (in the event of an error).
2466 * </p>
2467 * <p>
2468 * Applications can terminate the stream by throwing a
2469 * {@link RuntimeException} from the {@link StreamCallback#callback} method
2470 * (which will then call the {@link StreamCallback#exception} method or by
2471 * closing the {@link MongoCursorControl} returned from this method.
2472 * </p>
2473 * <p>
2474 * Only a single thread will invoke the callback at a time but that thread
2475 * may change over time.
2476 * </p>
2477 * <p>
2478 * If the callback processing requires any significant time (including I/O)
2479 * it is recommended that an
2480 * {@link MongoClientConfiguration#setExecutor(java.util.concurrent.Executor)
2481 * Executor} be configured within the {@link MongoClientConfiguration} to
2482 * off-load the processing from the receive thread.
2483 * </p>
2484 *
2485 * @param results
2486 * Callback that will be notified of the results of the query.
2487 * @param query
2488 * The query details.
2489 * @return A {@link MongoCursorControl} to control the cursor streaming
2490 * documents to the caller. This includes the ability to stop the
2491 * cursor and persist its state.
2492 * @throws MongoDbException
2493 * On an error finding the documents.
2494 * @deprecated Use the {@link #stream(StreamCallback, Find.Builder)} method
2495 * instead. This method will be removed after the 1.4.0 release.
2496 */
2497 @Deprecated
2498 public MongoCursorControl streamingFind(StreamCallback<Document> results,
2499 Find.Builder query) throws MongoDbException;
2500
2501 /**
2502 * Invokes a {@code text} command on the server.
2503 *
2504 * @param results
2505 * Callback for the {@code text} results returned.
2506 * @param command
2507 * The details of the {@code text} request.
2508 * @throws MongoDbException
2509 * On an error executing the {@code text} command.
2510 * @see <a
2511 * href="http://docs.mongodb.org/manual/release-notes/2.4/#text-queries">
2512 * MongoDB Text Queries</a>
2513 * @since MongoDB 2.4
2514 * @deprecated Support for the {@code text} command was deprecated in the
2515 * 2.6 version of MongoDB. Use the
2516 * {@link ConditionBuilder#text(String) $text} query operator
2517 * instead. This method will not be removed until two releases
2518 * after the MongoDB 2.6 release (e.g. 2.10 if the releases are
2519 * 2.8 and 2.10).
2520 */
2521 @Deprecated
2522 public void textSearchAsync(
2523 Callback<MongoIterator<com.allanbank.mongodb.builder.TextResult>> results,
2524 com.allanbank.mongodb.builder.Text command) throws MongoDbException;
2525
2526 /**
2527 * Invokes a {@code text} command on the server.
2528 *
2529 * @param results
2530 * Callback for the {@code text} results returned.
2531 * @param command
2532 * The details of the {@code text} request.
2533 * @throws MongoDbException
2534 * On an error executing the {@code text} command.
2535 * @deprecated Support for the {@code text} command was deprecated in the
2536 * 2.6 version of MongoDB. Use the
2537 * {@link ConditionBuilder#text(String) $text} query operator
2538 * instead. This method will not be removed until two releases
2539 * after the MongoDB 2.6 release (e.g. 2.10 if the releases are
2540 * 2.8 and 2.10).
2541 */
2542 @Deprecated
2543 public void textSearchAsync(
2544 Callback<MongoIterator<com.allanbank.mongodb.builder.TextResult>> results,
2545 com.allanbank.mongodb.builder.Text.Builder command)
2546 throws MongoDbException;
2547
2548 /**
2549 * Invokes a {@code text} command on the server.
2550 *
2551 * @param command
2552 * The details of the {@code text} request.
2553 * @return ListenableFuture for the {@code text} results returned.
2554 * @throws MongoDbException
2555 * On an error executing the {@code text} command.
2556 * @see <a
2557 * href="http://docs.mongodb.org/manual/release-notes/2.4/#text-queries">
2558 * MongoDB Text Queries</a>
2559 * @since MongoDB 2.4
2560 * @deprecated Support for the {@code text} command was deprecated in the
2561 * 2.6 version of MongoDB. Use the
2562 * {@link ConditionBuilder#text(String) $text} query operator
2563 * instead. This method will not be removed until two releases
2564 * after the MongoDB 2.6 release (e.g. 2.10 if the releases are
2565 * 2.8 and 2.10).
2566 */
2567 @Deprecated
2568 public ListenableFuture<MongoIterator<com.allanbank.mongodb.builder.TextResult>> textSearchAsync(
2569 com.allanbank.mongodb.builder.Text command) throws MongoDbException;
2570
2571 /**
2572 * Invokes a {@code text} command on the server.
2573 *
2574 * @param command
2575 * The details of the {@code text} request.
2576 * @return ListenableFuture for the {@code text} results returned.
2577 * @throws MongoDbException
2578 * On an error executing the {@code text} command.
2579 * @see <a
2580 * href="http://docs.mongodb.org/manual/release-notes/2.4/#text-queries">
2581 * MongoDB Text Queries</a>
2582 * @since MongoDB 2.4
2583 * @deprecated Support for the {@code text} command was deprecated in the
2584 * 2.6 version of MongoDB. Use the
2585 * {@link ConditionBuilder#text(String) $text} query operator
2586 * instead. This method will not be removed until two releases
2587 * after the MongoDB 2.6 release (e.g. 2.10 if the releases are
2588 * 2.8 and 2.10).
2589 */
2590 @Deprecated
2591 public ListenableFuture<MongoIterator<com.allanbank.mongodb.builder.TextResult>> textSearchAsync(
2592 com.allanbank.mongodb.builder.Text.Builder command)
2593 throws MongoDbException;
2594
2595 /**
2596 * Applies updates to a set of documents within the collection. The
2597 * documents to update are selected by the <tt>query</tt> and the updates
2598 * are describe by the <tt>update</tt> document.
2599 *
2600 * @param results
2601 * The {@link Callback} that will be notified of the number of
2602 * documents updated. If the durability of the operation is NONE
2603 * then this will be -1.
2604 * @param query
2605 * The query to select the documents to update.
2606 * @param update
2607 * The updates to apply to the selected documents.
2608 * @throws MongoDbException
2609 * On an error updating the documents.
2610 */
2611 public void updateAsync(Callback<Long> results, DocumentAssignable query,
2612 DocumentAssignable update) throws MongoDbException;
2613
2614 /**
2615 * Applies updates to a set of documents within the collection. The
2616 * documents to update are selected by the <tt>query</tt> and the updates
2617 * are describe by the <tt>update</tt> document.
2618 *
2619 * @param results
2620 * The {@link Callback} that will be notified of the number of
2621 * documents updated. If the durability of the operation is NONE
2622 * then this will be -1.
2623 * @param query
2624 * The query to select the documents to update.
2625 * @param update
2626 * The updates to apply to the selected documents.
2627 * @param multiUpdate
2628 * If true then the update is applied to all of the matching
2629 * documents, otherwise only the first document found is updated.
2630 * @param upsert
2631 * If true then if no document is found then a new document is
2632 * created and updated, otherwise no operation is performed.
2633 * @throws MongoDbException
2634 * On an error updating the documents.
2635 */
2636 public void updateAsync(Callback<Long> results, DocumentAssignable query,
2637 DocumentAssignable update, boolean multiUpdate, boolean upsert)
2638 throws MongoDbException;
2639
2640 /**
2641 * Applies updates to a set of documents within the collection. The
2642 * documents to update are selected by the <tt>query</tt> and the updates
2643 * are describe by the <tt>update</tt> document.
2644 *
2645 * @param results
2646 * The {@link Callback} that will be notified of the number of
2647 * documents updated. If the durability of the operation is NONE
2648 * then this will be -1.
2649 * @param query
2650 * The query to select the documents to update.
2651 * @param update
2652 * The updates to apply to the selected documents.
2653 * @param multiUpdate
2654 * If true then the update is applied to all of the matching
2655 * documents, otherwise only the first document found is updated.
2656 * @param upsert
2657 * If true then if no document is found then a new document is
2658 * created and updated, otherwise no operation is performed.
2659 * @param durability
2660 * The durability for the update.
2661 * @throws MongoDbException
2662 * On an error updating the documents.
2663 */
2664 public void updateAsync(Callback<Long> results, DocumentAssignable query,
2665 DocumentAssignable update, boolean multiUpdate, boolean upsert,
2666 Durability durability) throws MongoDbException;
2667
2668 /**
2669 * Applies updates to a set of documents within the collection. The
2670 * documents to update are selected by the <tt>query</tt> and the updates
2671 * are describe by the <tt>update</tt> document.
2672 *
2673 * @param results
2674 * The {@link Callback} that will be notified of the number of
2675 * documents updated. If the durability of the operation is NONE
2676 * then this will be -1.
2677 * @param query
2678 * The query to select the documents to update.
2679 * @param update
2680 * The updates to apply to the selected documents.
2681 * @param durability
2682 * The durability for the update.
2683 * @throws MongoDbException
2684 * On an error updating the documents.
2685 */
2686 public void updateAsync(Callback<Long> results, DocumentAssignable query,
2687 DocumentAssignable update, Durability durability)
2688 throws MongoDbException;
2689
2690 /**
2691 * Applies updates to a set of documents within the collection. The
2692 * documents to update are selected by the <tt>query</tt> and the updates
2693 * are describe by the <tt>update</tt> document.
2694 *
2695 * @param query
2696 * The query to select the documents to update.
2697 * @param update
2698 * The updates to apply to the selected documents.
2699 * @return A {@link ListenableFuture} that will be updated with the number
2700 * of documents updated. If the durability of the operation is NONE
2701 * then this will be -1.
2702 * @throws MongoDbException
2703 * On an error updating the documents.
2704 */
2705 public ListenableFuture<Long> updateAsync(DocumentAssignable query,
2706 DocumentAssignable update) throws MongoDbException;
2707
2708 /**
2709 * Applies updates to a set of documents within the collection. The
2710 * documents to update are selected by the <tt>query</tt> and the updates
2711 * are describe by the <tt>update</tt> document.
2712 *
2713 * @param query
2714 * The query to select the documents to update.
2715 * @param update
2716 * The updates to apply to the selected documents.
2717 * @param multiUpdate
2718 * If true then the update is applied to all of the matching
2719 * documents, otherwise only the first document found is updated.
2720 * @param upsert
2721 * If true then if no document is found then a new document is
2722 * created and updated, otherwise no operation is performed.
2723 * @return A {@link ListenableFuture} that will be updated with the number
2724 * of documents updated. If the durability of the operation is NONE
2725 * then this will be -1.
2726 * @throws MongoDbException
2727 * On an error updating the documents.
2728 */
2729 public ListenableFuture<Long> updateAsync(DocumentAssignable query,
2730 DocumentAssignable update, boolean multiUpdate, boolean upsert)
2731 throws MongoDbException;
2732
2733 /**
2734 * Applies updates to a set of documents within the collection. The
2735 * documents to update are selected by the <tt>query</tt> and the updates
2736 * are describe by the <tt>update</tt> document.
2737 *
2738 * @param query
2739 * The query to select the documents to update.
2740 * @param update
2741 * The updates to apply to the selected documents.
2742 * @param multiUpdate
2743 * If true then the update is applied to all of the matching
2744 * documents, otherwise only the first document found is updated.
2745 * @param upsert
2746 * If true then if no document is found then a new document is
2747 * created and updated, otherwise no operation is performed.
2748 * @param durability
2749 * The durability for the update.
2750 * @return A {@link ListenableFuture} that will be updated with the number
2751 * of documents updated. If the durability of the operation is NONE
2752 * then this will be -1.
2753 * @throws MongoDbException
2754 * On an error updating the documents.
2755 */
2756 public ListenableFuture<Long> updateAsync(DocumentAssignable query,
2757 DocumentAssignable update, boolean multiUpdate, boolean upsert,
2758 Durability durability) throws MongoDbException;
2759
2760 /**
2761 * Applies updates to a set of documents within the collection. The
2762 * documents to update are selected by the <tt>query</tt> and the updates
2763 * are describe by the <tt>update</tt> document.
2764 *
2765 * @param query
2766 * The query to select the documents to update.
2767 * @param update
2768 * The updates to apply to the selected documents.
2769 * @param durability
2770 * The durability for the update.
2771 * @return A {@link ListenableFuture} that will be updated with the number
2772 * of documents updated. If the durability of the operation is NONE
2773 * then this will be -1.
2774 * @throws MongoDbException
2775 * On an error updating the documents.
2776 */
2777 public ListenableFuture<Long> updateAsync(DocumentAssignable query,
2778 DocumentAssignable update, Durability durability)
2779 throws MongoDbException;
2780
2781 /**
2782 * Applies updates to a set of documents within the collection. The
2783 * documents to update are selected by the <tt>query</tt> and the updates
2784 * are describe by the <tt>update</tt> document.
2785 *
2786 * @param results
2787 * The {@link LambdaCallback} that will be notified of the number
2788 * of documents updated. If the durability of the operation is
2789 * NONE then this will be -1.
2790 * @param query
2791 * The query to select the documents to update.
2792 * @param update
2793 * The updates to apply to the selected documents.
2794 * @throws MongoDbException
2795 * On an error updating the documents.
2796 */
2797 public void updateAsync(LambdaCallback<Long> results,
2798 DocumentAssignable query, DocumentAssignable update)
2799 throws MongoDbException;
2800
2801 /**
2802 * Applies updates to a set of documents within the collection. The
2803 * documents to update are selected by the <tt>query</tt> and the updates
2804 * are describe by the <tt>update</tt> document.
2805 *
2806 * @param results
2807 * The {@link LambdaCallback} that will be notified of the number
2808 * of documents updated. If the durability of the operation is
2809 * NONE then this will be -1.
2810 * @param query
2811 * The query to select the documents to update.
2812 * @param update
2813 * The updates to apply to the selected documents.
2814 * @param multiUpdate
2815 * If true then the update is applied to all of the matching
2816 * documents, otherwise only the first document found is updated.
2817 * @param upsert
2818 * If true then if no document is found then a new document is
2819 * created and updated, otherwise no operation is performed.
2820 * @throws MongoDbException
2821 * On an error updating the documents.
2822 */
2823 public void updateAsync(LambdaCallback<Long> results,
2824 DocumentAssignable query, DocumentAssignable update,
2825 boolean multiUpdate, boolean upsert) throws MongoDbException;
2826
2827 /**
2828 * Applies updates to a set of documents within the collection. The
2829 * documents to update are selected by the <tt>query</tt> and the updates
2830 * are describe by the <tt>update</tt> document.
2831 *
2832 * @param results
2833 * The {@link LambdaCallback} that will be notified of the number
2834 * of documents updated. If the durability of the operation is
2835 * NONE then this will be -1.
2836 * @param query
2837 * The query to select the documents to update.
2838 * @param update
2839 * The updates to apply to the selected documents.
2840 * @param multiUpdate
2841 * If true then the update is applied to all of the matching
2842 * documents, otherwise only the first document found is updated.
2843 * @param upsert
2844 * If true then if no document is found then a new document is
2845 * created and updated, otherwise no operation is performed.
2846 * @param durability
2847 * The durability for the update.
2848 * @throws MongoDbException
2849 * On an error updating the documents.
2850 */
2851 public void updateAsync(LambdaCallback<Long> results,
2852 DocumentAssignable query, DocumentAssignable update,
2853 boolean multiUpdate, boolean upsert, Durability durability)
2854 throws MongoDbException;
2855
2856 /**
2857 * Applies updates to a set of documents within the collection. The
2858 * documents to update are selected by the <tt>query</tt> and the updates
2859 * are describe by the <tt>update</tt> document.
2860 *
2861 * @param results
2862 * The {@link LambdaCallback} that will be notified of the number
2863 * of documents updated. If the durability of the operation is
2864 * NONE then this will be -1.
2865 * @param query
2866 * The query to select the documents to update.
2867 * @param update
2868 * The updates to apply to the selected documents.
2869 * @param durability
2870 * The durability for the update.
2871 * @throws MongoDbException
2872 * On an error updating the documents.
2873 */
2874 public void updateAsync(LambdaCallback<Long> results,
2875 DocumentAssignable query, DocumentAssignable update,
2876 Durability durability) throws MongoDbException;
2877
2878 /**
2879 * Constructs the appropriate set of write commands to send to the server.
2880 * <p>
2881 * If connected to a cluster where all servers can accept write commands
2882 * then the operations will be sent to the server using the write commands.
2883 * If the cluster does not support the write command then the operations
2884 * will be converted to a series of native write operations.
2885 * </p>
2886 * <p>
2887 * Since this method may use the write commands a {@link Durability} of
2888 * {@link Durability#NONE} will be changed to {@link Durability#ACK}.
2889 * </p>
2890 *
2891 * @param write
2892 * The batched writes
2893 * @return ListenableFuture that will be updated with the results of the
2894 * inserts, updates, and deletes. If this method falls back to the
2895 * native write commands then the notice for the {@code return} for
2896 * the {@link #insertAsync(DocumentAssignable...)} method applies.
2897 * @throws MongoDbException
2898 * On an error submitting the write operations.
2899 *
2900 * @since MongoDB 2.6
2901 * @see BatchedWrite#REQUIRED_VERSION
2902 */
2903 public ListenableFuture<Long> writeAsync(BatchedWrite write)
2904 throws MongoDbException;
2905
2906 /**
2907 * Constructs the appropriate set of write commands to send to the server.
2908 * <p>
2909 * If connected to a cluster where all servers can accept write commands
2910 * then the operations will be sent to the server using the write commands.
2911 * If the cluster does not support the write command then the operations
2912 * will be converted to a series of native write operations.
2913 * </p>
2914 * <p>
2915 * Since this method may use the write commands a {@link Durability} of
2916 * {@link Durability#NONE} will be changed to {@link Durability#ACK}.
2917 * </p>
2918 *
2919 * @param write
2920 * The batched writes
2921 * @return ListenableFuture that will be updated with the results of the
2922 * inserts, updates, and deletes. If this method falls back to the
2923 * native write commands then the notice for the {@code return} for
2924 * the {@link #insertAsync(DocumentAssignable...)} method applies.
2925 * @throws MongoDbException
2926 * On an error submitting the write operations.
2927 *
2928 * @since MongoDB 2.6
2929 * @see BatchedWrite#REQUIRED_VERSION
2930 */
2931 public ListenableFuture<Long> writeAsync(BatchedWrite.Builder write)
2932 throws MongoDbException;
2933
2934 /**
2935 * Constructs the appropriate set of write commands to send to the server.
2936 * <p>
2937 * If connected to a cluster where all servers can accept write commands
2938 * then the operations will be sent to the server using the write commands.
2939 * If the cluster does not support the write command then the operations
2940 * will be converted to a series of native write operations.
2941 * </p>
2942 * <p>
2943 * Since this method may use the write commands a {@link Durability} of
2944 * {@link Durability#NONE} will be changed to {@link Durability#ACK}.
2945 * </p>
2946 *
2947 * @param results
2948 * The {@link Callback} that will be notified of the number of
2949 * documents inserted, updated, and deleted. If this method falls
2950 * back to the native write commands then the notice for the
2951 * {@code results} parameter for the
2952 * {@link #insertAsync(Callback, DocumentAssignable...)} method
2953 * applies.
2954 * @param write
2955 * The batched writes
2956 * @throws MongoDbException
2957 * On an error submitting the write operations.
2958 *
2959 * @since MongoDB 2.6
2960 * @see BatchedWrite#REQUIRED_VERSION
2961 */
2962 public void writeAsync(Callback<Long> results, BatchedWrite write)
2963 throws MongoDbException;
2964
2965 /**
2966 * Constructs the appropriate set of write commands to send to the server.
2967 * <p>
2968 * If connected to a cluster where all servers can accept write commands
2969 * then the operations will be sent to the server using the write commands.
2970 * If the cluster does not support the write command then the operations
2971 * will be converted to a series of native write operations.
2972 * </p>
2973 * <p>
2974 * Since this method may use the write commands a {@link Durability} of
2975 * {@link Durability#NONE} will be changed to {@link Durability#ACK}.
2976 * </p>
2977 *
2978 * @param results
2979 * The {@link Callback} that will be notified of the number of
2980 * documents inserted, updated, and deleted. If this method falls
2981 * back to the native write commands then the notice for the
2982 * {@code results} parameter for the
2983 * {@link #insertAsync(Callback, DocumentAssignable...)} method
2984 * applies.
2985 * @param write
2986 * The batched writes
2987 * @throws MongoDbException
2988 * On an error submitting the write operations.
2989 *
2990 * @since MongoDB 2.6
2991 * @see BatchedWrite#REQUIRED_VERSION
2992 */
2993 public void writeAsync(Callback<Long> results, BatchedWrite.Builder write)
2994 throws MongoDbException;
2995
2996 /**
2997 * Constructs the appropriate set of write commands to send to the server.
2998 * <p>
2999 * If connected to a cluster where all servers can accept write commands
3000 * then the operations will be sent to the server using the write commands.
3001 * If the cluster does not support the write command then the operations
3002 * will be converted to a series of native write operations.
3003 * </p>
3004 * <p>
3005 * Since this method may use the write commands a {@link Durability} of
3006 * {@link Durability#NONE} will be changed to {@link Durability#ACK}.
3007 * </p>
3008 *
3009 * @param results
3010 * The {@link Callback} that will be notified of the number of
3011 * documents inserted, updated, and deleted. If this method falls
3012 * back to the native write commands then the notice for the
3013 * {@code results} parameter for the
3014 * {@link #insertAsync(Callback, DocumentAssignable...)} method
3015 * applies.
3016 * @param write
3017 * The batched writes
3018 * @throws MongoDbException
3019 * On an error submitting the write operations.
3020 *
3021 * @since MongoDB 2.6
3022 * @see BatchedWrite#REQUIRED_VERSION
3023 */
3024 public void writeAsync(LambdaCallback<Long> results, BatchedWrite write)
3025 throws MongoDbException;
3026
3027 /**
3028 * Constructs the appropriate set of write commands to send to the server.
3029 * <p>
3030 * If connected to a cluster where all servers can accept write commands
3031 * then the operations will be sent to the server using the write commands.
3032 * If the cluster does not support the write command then the operations
3033 * will be converted to a series of native write operations.
3034 * </p>
3035 * <p>
3036 * Since this method may use the write commands a {@link Durability} of
3037 * {@link Durability#NONE} will be changed to {@link Durability#ACK}.
3038 * </p>
3039 *
3040 * @param results
3041 * The {@link Callback} that will be notified of the number of
3042 * documents inserted, updated, and deleted. If this method falls
3043 * back to the native write commands then the notice for the
3044 * {@code results} parameter for the
3045 * {@link #insertAsync(Callback, DocumentAssignable...)} method
3046 * applies.
3047 * @param write
3048 * The batched writes
3049 * @throws MongoDbException
3050 * On an error submitting the write operations.
3051 *
3052 * @since MongoDB 2.6
3053 * @see BatchedWrite#REQUIRED_VERSION
3054 */
3055 public void writeAsync(LambdaCallback<Long> results,
3056 BatchedWrite.Builder write) throws MongoDbException;
3057
3058 }