@@ -466,6 +466,13 @@ namespace internal {
466
466
return *this ;
467
467
}
468
468
469
+ /* *
470
+ Specify ordering of documents in the operation.
471
+
472
+ This form accepts a vector, list or other container with strings, each
473
+ string defining sorting direction and the value to sort on.
474
+ */
475
+
469
476
template <typename Ord>
470
477
Limit<Res, limit_with_offset>& sort (Ord ord)
471
478
{
@@ -476,6 +483,13 @@ namespace internal {
476
483
return *this ;
477
484
}
478
485
486
+ /* *
487
+ Specify ordering of documents in the operation.
488
+
489
+ Arguments are one or more strings, each defining sorting direction and the
490
+ value to sort on.
491
+ */
492
+
479
493
template <typename Ord, typename ...Type>
480
494
Limit<Res, limit_with_offset>& sort (Ord ord, const Type...rest)
481
495
{
@@ -559,7 +573,7 @@ namespace internal {
559
573
public:
560
574
561
575
/* *
562
- Remove all documents from the collection.
576
+ Return operation which removes all documents from the collection.
563
577
*/
564
578
565
579
virtual CollectionRemove remove ()
@@ -568,7 +582,7 @@ namespace internal {
568
582
}
569
583
570
584
/* *
571
- Remove documents satisfying given expression.
585
+ Return operation which removes documents satisfying given expression.
572
586
*/
573
587
574
588
virtual CollectionRemove remove (const string &cond)
@@ -653,6 +667,13 @@ DIAGNOSTIC_POP
653
667
654
668
public:
655
669
670
+ /* *
671
+ Specify projection for documents found in the collection.
672
+
673
+ The projection should be an expression given by `expr(<string>)`
674
+ which evaluates to a document. Each document found will be transformed by
675
+ evaluating the expression an the result will be returned by the operation.
676
+ */
656
677
657
678
CollectionSort& fields (internal::ExprValue proj)
658
679
{
@@ -675,6 +696,18 @@ DIAGNOSTIC_POP
675
696
return *this ;
676
697
}
677
698
699
+ /* *
700
+ Specify projection for documents found in the collection.
701
+
702
+ In this form the projection is given as list of strings of the form
703
+ `"<expression> AS <path>"`. Each expression is evaluated and `<path>`
704
+ specifies where to put the value of the expression in the resulting
705
+ document.
706
+
707
+ The strings which define the projection are passed as a vector, list
708
+ or other container with strings.
709
+ */
710
+
678
711
template <typename Ord>
679
712
CollectionSort& fields (const Ord& ord)
680
713
{
@@ -685,6 +718,15 @@ DIAGNOSTIC_POP
685
718
return *this ;
686
719
}
687
720
721
+ /* *
722
+ Specify projection for documents found in the collection.
723
+
724
+ In this form the projection is given as list of strings of the form
725
+ `"<expression> AS <path>"`. Each expression is evaluated and `<path>`
726
+ specifies where to put the value of the expression in the resulting
727
+ document.
728
+ */
729
+
688
730
/*
689
731
Note: If e is an expression (of type ExprValue) then only
690
732
.fields(e) is valid - the multi-argument variant .fields(e,...)
@@ -720,7 +762,7 @@ namespace internal {
720
762
public:
721
763
722
764
/* *
723
- Return all the documents in the collection.
765
+ Return operation which fetches all the documents in the collection.
724
766
*/
725
767
726
768
CollectionFind find ()
@@ -729,7 +771,7 @@ namespace internal {
729
771
}
730
772
731
773
/* *
732
- Find documents that satisfy given expression.
774
+ Return opertion which finds documents that satisfy given expression.
733
775
*/
734
776
735
777
CollectionFind find (const string &cond)
@@ -836,6 +878,13 @@ DIAGNOSTIC_PUSH
836
878
837
879
DIAGNOSTIC_POP
838
880
881
+ /* *
882
+ Set a given field in a docuemnt to the given value.
883
+
884
+ Field is given by a document path. The value can be either a direct literal
885
+ or an expression given by `expr(<string>)`, evaluated in the server.
886
+ */
887
+
839
888
CollectionModify& set (const Field &field, internal::ExprValue &&val)
840
889
{
841
890
try {
@@ -845,6 +894,12 @@ DIAGNOSTIC_POP
845
894
CATCH_AND_WRAP
846
895
}
847
896
897
+ /* *
898
+ Unset a given field in a document.
899
+
900
+ The field is given by a document path.
901
+ */
902
+
848
903
CollectionModify& unset (const Field &field)
849
904
{
850
905
try {
@@ -854,6 +909,13 @@ DIAGNOSTIC_POP
854
909
CATCH_AND_WRAP
855
910
}
856
911
912
+ /* *
913
+ Insert value into an array field of a document.
914
+
915
+ The `field` parameter should be a document path pointing at a location
916
+ inside an array field. The given value is inserted at this position.
917
+ */
918
+
857
919
CollectionModify& arrayInsert (const Field &field, internal::ExprValue &&val)
858
920
{
859
921
try {
@@ -863,6 +925,14 @@ DIAGNOSTIC_POP
863
925
CATCH_AND_WRAP
864
926
}
865
927
928
+ /* *
929
+ Append value to an array field of a document.
930
+
931
+ The `field` parameter should be a document path pointing at an array
932
+ field inside the document. The given value is appended at the end of the
933
+ array.
934
+ */
935
+
866
936
CollectionModify& arrayAppend (const Field &field, internal::ExprValue &&val)
867
937
{
868
938
try {
@@ -872,6 +942,14 @@ DIAGNOSTIC_POP
872
942
CATCH_AND_WRAP
873
943
}
874
944
945
+ /* *
946
+ Delete element from an array field of a document.
947
+
948
+ The `field` parameter should be a document path pointing at a location
949
+ inside an array field. The element at indicated location is removed from
950
+ the array.
951
+ */
952
+
875
953
CollectionModify& arrayDelete (const Field &field)
876
954
{
877
955
try {
@@ -899,7 +977,7 @@ namespace internal {
899
977
public:
900
978
901
979
/* *
902
- Modify all documents.
980
+ Return operation which modifies all documents in the collection .
903
981
*/
904
982
905
983
CollectionModify modify ()
@@ -911,7 +989,7 @@ namespace internal {
911
989
}
912
990
913
991
/* *
914
- Modify documents that satisfy given expression.
992
+ Return operation which modifies documents that satisfy given expression.
915
993
*/
916
994
917
995
CollectionModify modify (const string &expr)
0 commit comments