diff --git a/.nojekyll b/.nojekyll new file mode 100644 index 0000000..e69de29 diff --git a/404.html b/404.html new file mode 100755 index 0000000..66b7d8e --- /dev/null +++ b/404.html @@ -0,0 +1,268 @@ + + + +
+ + + + + + + + + + + + + + +Pipeline Module
+ + + +Pipeline
+
+
+
+ Bases: BaseModel
MongoDB aggregation pipeline abstraction
+- collection, str : reference collection for the pipeline.
+ This is the collection where the aggregation will be done.
+ However some stages in the pipeline might work with additional
+ collections (e.g. lookup stage)
+
+- stages, list[Stage] : the list of Stages that the pipeline is made of.
+ Similarly to the pipeline itself. This package constructs
+ abstraction for MongoDB aggregation framework pipeline stages.
+
+- on_call, OnCallEnum : pipeline instances are callable. This defines the behavior of the instance
+ when called. See OnCallEnum above. Defaults to export
+
+- -db, Database : pymongo database instance. Can be optionally provided to make a pipeline instance self sufficient
+
You can instantiate a pipeline instance as follow:
+>>> pipeline = Pipeline(collection="listingsAndReviews") # collection is the only mandatory attribute
+ # example using MongoDB AirBnB demo dataset : https://www.mongodb.com/docs/atlas/sample-data/sample-airbnb/#std-label-sample-airbnb
+
and then add stages to the pipeline by calling its wrapper stages method as shown below:
+>>> pipeline.match(
+ query = { "room_type": "Entire home/apt"}
+).sort_by_count(
+ by = "bed_type"
+)
+
and then use this pipeline in your own code:
+>>> db["listingsAndReviews"].aggregate(pipeline=pipeline()) # pipeline() here is actually equivalent to pipeline.export()
+
Alternatively, your pipeline can be self sufficient and executes itself directly using the following approach:
+>>> pipeline = Pipeline(
+ _db=db,
+ collection="listingsAndReviews",
+ on_call="run"
+)
+
+>>> pipeline.match(
+ query = { "room_type": "Entire home/apt"}
+).sort_by_count(
+ by = "bed_type"
+)
+
+>>> pipeline() # pipeline() there is actually equivalent to pipeline.run()
+
monggregate\pipeline.py
41 + 42 + 43 + 44 + 45 + 46 + 47 + 48 + 49 + 50 + 51 + 52 + 53 + 54 + 55 + 56 + 57 + 58 + 59 + 60 + 61 + 62 + 63 + 64 + 65 + 66 + 67 + 68 + 69 + 70 + 71 + 72 + 73 + 74 + 75 + 76 + 77 + 78 + 79 + 80 + 81 + 82 + 83 + 84 + 85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 + 100 + 101 + 102 + 103 + 104 + 105 + 106 + 107 + 108 + 109 + 110 + 111 + 112 + 113 + 114 + 115 + 116 + 117 + 118 + 119 + 120 + 121 + 122 + 123 + 124 + 125 + 126 + 127 + 128 + 129 + 130 + 131 + 132 + 133 + 134 + 135 + 136 + 137 + 138 + 139 + 140 + 141 + 142 + 143 + 144 + 145 + 146 + 147 + 148 + 149 + 150 + 151 + 152 + 153 + 154 + 155 + 156 + 157 + 158 + 159 + 160 + 161 + 162 + 163 + 164 + 165 + 166 + 167 + 168 + 169 + 170 + 171 + 172 + 173 + 174 + 175 + 176 + 177 + 178 + 179 + 180 + 181 + 182 + 183 + 184 + 185 + 186 + 187 + 188 + 189 + 190 + 191 + 192 + 193 + 194 + 195 + 196 + 197 + 198 + 199 + 200 + 201 + 202 + 203 + 204 + 205 + 206 + 207 + 208 + 209 + 210 + 211 + 212 + 213 + 214 + 215 + 216 + 217 + 218 + 219 + 220 + 221 + 222 + 223 + 224 + 225 + 226 + 227 + 228 + 229 + 230 + 231 + 232 + 233 + 234 + 235 + 236 + 237 + 238 + 239 + 240 + 241 + 242 + 243 + 244 + 245 + 246 + 247 + 248 + 249 + 250 + 251 + 252 + 253 + 254 + 255 + 256 + 257 + 258 + 259 + 260 + 261 + 262 + 263 + 264 + 265 + 266 + 267 + 268 + 269 + 270 + 271 + 272 + 273 + 274 + 275 + 276 + 277 + 278 + 279 + 280 + 281 + 282 + 283 + 284 + 285 + 286 + 287 + 288 + 289 + 290 + 291 + 292 + 293 + 294 + 295 + 296 + 297 + 298 + 299 + 300 + 301 + 302 + 303 + 304 + 305 + 306 + 307 + 308 + 309 + 310 + 311 + 312 + 313 + 314 + 315 + 316 + 317 + 318 + 319 + 320 + 321 + 322 + 323 + 324 + 325 + 326 + 327 + 328 + 329 + 330 + 331 + 332 + 333 + 334 + 335 + 336 + 337 + 338 + 339 + 340 + 341 + 342 + 343 + 344 + 345 + 346 + 347 + 348 + 349 + 350 + 351 + 352 + 353 + 354 + 355 + 356 + 357 + 358 + 359 + 360 + 361 + 362 + 363 + 364 + 365 + 366 + 367 + 368 + 369 + 370 + 371 + 372 + 373 + 374 + 375 + 376 + 377 + 378 + 379 + 380 + 381 + 382 + 383 + 384 + 385 + 386 + 387 + 388 + 389 + 390 + 391 + 392 + 393 + 394 + 395 + 396 + 397 + 398 + 399 + 400 + 401 + 402 + 403 + 404 + 405 + 406 + 407 + 408 + 409 + 410 + 411 + 412 + 413 + 414 + 415 + 416 + 417 + 418 + 419 + 420 + 421 + 422 + 423 + 424 + 425 + 426 + 427 + 428 + 429 + 430 + 431 + 432 + 433 + 434 + 435 + 436 + 437 + 438 + 439 + 440 + 441 + 442 + 443 + 444 + 445 + 446 + 447 + 448 + 449 + 450 + 451 + 452 + 453 + 454 + 455 + 456 + 457 + 458 + 459 + 460 + 461 + 462 + 463 + 464 + 465 + 466 + 467 + 468 + 469 + 470 + 471 + 472 + 473 + 474 + 475 + 476 + 477 + 478 + 479 + 480 + 481 + 482 + 483 + 484 + 485 + 486 + 487 + 488 + 489 + 490 + 491 + 492 + 493 + 494 + 495 + 496 + 497 + 498 + 499 + 500 + 501 + 502 + 503 + 504 + 505 + 506 + 507 + 508 + 509 + 510 + 511 + 512 + 513 + 514 + 515 + 516 + 517 + 518 + 519 + 520 + 521 + 522 + 523 + 524 + 525 + 526 + 527 + 528 + 529 + 530 + 531 + 532 + 533 + 534 + 535 + 536 + 537 + 538 + 539 + 540 + 541 + 542 + 543 + 544 + 545 + 546 + 547 + 548 + 549 + 550 + 551 + 552 + 553 + 554 + 555 + 556 + 557 + 558 + 559 + 560 + 561 + 562 + 563 + 564 + 565 + 566 + 567 + 568 + 569 + 570 + 571 + 572 + 573 + 574 + 575 + 576 + 577 + 578 + 579 + 580 + 581 + 582 + 583 + 584 + 585 + 586 + 587 + 588 + 589 + 590 + 591 + 592 + 593 + 594 + 595 + 596 + 597 + 598 + 599 + 600 + 601 + 602 + 603 + 604 + 605 + 606 + 607 + 608 + 609 + 610 + 611 + 612 + 613 + 614 + 615 + 616 + 617 + 618 + 619 + 620 + 621 + 622 + 623 + 624 + 625 + 626 + 627 + 628 + 629 + 630 + 631 + 632 + 633 + 634 + 635 + 636 + 637 + 638 + 639 + 640 + 641 + 642 + 643 + 644 + 645 + 646 + 647 + 648 + 649 + 650 + 651 + 652 + 653 + 654 + 655 + 656 + 657 + 658 + 659 + 660 + 661 + 662 + 663 + 664 + 665 + 666 + 667 + 668 + 669 + 670 + 671 + 672 + 673 + 674 + 675 + 676 + 677 + 678 + 679 + 680 + 681 + 682 + 683 + 684 + 685 + 686 + 687 + 688 + 689 + 690 + 691 + 692 + 693 + 694 + 695 + 696 + 697 + 698 + 699 + 700 + 701 + 702 + 703 + 704 + 705 + 706 + 707 + 708 + 709 + 710 + 711 + 712 + 713 + 714 + 715 + 716 + 717 + 718 + 719 + 720 + 721 + 722 + 723 + 724 + 725 + 726 + 727 + 728 + 729 + 730 + 731 + 732 + 733 + 734 + 735 + 736 + 737 + 738 + 739 + 740 + 741 + 742 + 743 + 744 + 745 + 746 + 747 + 748 + 749 + 750 + 751 + 752 + 753 + 754 + 755 + 756 + 757 + 758 + 759 + 760 + 761 + 762 + 763 + 764 + 765 + 766 + 767 + 768 + 769 + 770 + 771 + 772 + 773 + 774 + 775 + 776 + 777 + 778 + 779 + 780 + 781 + 782 + 783 + 784 + 785 + 786 + 787 + 788 + 789 + 790 + 791 + 792 + 793 + 794 + 795 + 796 + 797 + 798 + 799 + 800 + 801 + 802 + 803 + 804 + 805 + 806 + 807 + 808 + 809 + 810 + 811 + 812 + 813 + 814 + 815 + 816 + 817 + 818 + 819 + 820 + 821 + 822 + 823 + 824 + 825 + 826 + 827 + 828 + 829 + 830 + 831 + 832 + 833 + 834 + 835 + 836 + 837 + 838 + 839 + 840 + 841 + 842 + 843 + 844 + 845 + 846 + 847 + 848 + 849 + 850 + 851 + 852 + 853 + 854 + 855 + 856 + 857 + 858 + 859 + 860 + 861 + 862 + 863 + 864 + 865 + 866 + 867 + 868 + 869 + 870 + 871 + 872 + 873 + 874 + 875 + 876 + 877 + 878 + 879 + 880 + 881 + 882 + 883 + 884 + 885 + 886 + 887 + 888 + 889 + 890 + 891 + 892 + 893 + 894 + 895 + 896 + 897 + 898 + 899 + 900 + 901 + 902 + 903 + 904 + 905 + 906 + 907 + 908 + 909 + 910 + 911 + 912 + 913 + 914 + 915 + 916 + 917 + 918 + 919 + 920 + 921 + 922 + 923 + 924 + 925 + 926 + 927 + 928 + 929 + 930 + 931 + 932 + 933 + 934 + 935 + 936 + 937 + 938 + 939 + 940 + 941 + 942 + 943 + 944 + 945 + 946 + 947 + 948 + 949 + 950 + 951 + 952 + 953 + 954 + 955 + 956 + 957 + 958 + 959 + 960 + 961 + 962 + 963 + 964 + 965 + 966 + 967 + 968 + 969 + 970 + 971 + 972 + 973 + 974 + 975 + 976 + 977 + 978 + 979 + 980 + 981 + 982 + 983 + 984 + 985 + 986 + 987 + 988 + 989 + 990 + 991 + 992 + 993 + 994 + 995 + 996 + 997 + 998 + 999 +1000 +1001 +1002 |
|
statement: list[dict]
+
+
+ property
+
+
+Returns the pipeline statement
+__add__(other)
+
+Concatenates two pipelines together
+ +monggregate\pipeline.py
__delitem__(index)
+
+__getitem__(index)
+
+__inner_join(right, on, left_on, right_on)
+
+Implements SQL inner join
+ +monggregate\pipeline.py
__join_common(right, on, left_on, right_on)
+
+Common parts between various join types
+ +monggregate\pipeline.py
__left_join(right, on, left_on, right_on)
+
+Implements SQL left join
+ + +__len__()
+
+__right_join(left, on, left_on, right_on)
+
+Implements SQL right join
+ +monggregate\pipeline.py
__setitem__(index, stage)
+
+add_fields(document={}, **kwargs)
+
+Adds an add_fields stage to the current pipeline.
+- statement, dict :
+- document, dict : new fields to be added
+
monggregate\pipeline.py
append(stage)
+
+bucket(*, by, boundaries, default=None, output=None)
+
+Adds a bucket stage to the current pipeline.
+by : str|list[str]|set[str], field or fields to group the documents
+ unless a default is provided, each input document
+ must resolve the groupBy field path or expression
+ to a value that falls within one of the ranges specified
+ by the boundaries
+boundaries : list, an array of values that specify the boundaries for each bucket.
+ Each adjacent pair of values acts as the inclusive lower boundary
+ and the exclusive upper boundary for the bucket.
+ NOTE : You must specify at least two boundaries.
+default : Any, Optional. A literal that specifies the _id (group name) of an additional
+ bucket that contains all documents whoe groupBy expression result
+ does not fall into a bucket specified by the boundaries
+
+ If unspecified, each input document must resolve groupBy
+ expression to a value within one of the bucket ranges.
+
+ The default value must be less than the lowest boundary or greather
+ than or equal to the highest boundary value
+
+ The default value can be of a different type than the entries in boundaries
+output : dict | None, A document that specifies the fields to include in the output documents in addition to
+ the _id field. To specify the field to include you must use accumulator expressions
+ >>> {"outputField1" : {"accumulator":"expression1}}
+ ....
+ {"outputField2" : {"accumulator":"expression2}}
+ If you do not specify an output document, the operation returns a count field containing
+ the number of documents in each bucket.
+
+ If you specify and output document, only the fields specified in the document are returned; i.e.
+ the count field is not returned unless it is explicitly included in the output document
+
monggregate\pipeline.py
bucket_auto(*, by, buckets, output=None, granularity=None)
+
+Adds a bucket_auto stage to the current pipeline
+by : str|list[str]|set[str], An expression to group documents. To specify a field path + prefix the field name with a dollar sign $ and enclose it in quotes. +buckets : int, number of buckets desired +output : dict, A document that specifieds the fields to include in the oupput documents in addition + to the _id field. To specify the field to include, you must use accumulator expressions.
+ The defaut count field is not included in the output document when output is specified. Explicitly specify the count expression
+ as part of the output document to include it:
+
+ >>> {
+ <outputfield1>: { <accumulator>: <expression1> },
+ ...
+ count: { $sum: 1 }
+ }
+
granularity : str | None, A string that specifies the preferred number series to use to ensure that the calculated + boundary edges end on preferred round numbers of their powers of 10.
+ Available only if the all groupBy values are numeric and none of them are NaN.
+ https://en.wikipedia.org/wiki/Preferred_number
+
monggregate\pipeline.py
count(name)
+
+Adds a count stage to the current pipeline
+- name, str : name of the output field which the count as its value.
+ Must be a non-empty string,
+ NOTE : Must not start with $ and must not contain the
+ . character and must not be empty
+
monggregate\pipeline.py
explode(path, *, include_array_index=None, always=False)
+
+Adds a unwind stage to the current pipeline.
+- path_to_array (path), str : path to an array field
+- include_array_index, str : name of a new field to hold the array index of the element
+ NOTE : The name cannot start with a dollar sign
+- always (preserve_null_and_empty_index), bool : whether to output documents for input documents where the path does not resolve to a valid array. Defaults to False
+
monggregate\pipeline.py
export()
+
+Exports current pipeline to pymongo format.
+>>> pipeline = Pipeline().match(...).project(...).limit(...).export()
+>>> db.examples.aggregate(pipeline=pipeline)
+
monggregate\pipeline.py
extend(stages)
+
+group(*, by=None, query={})
+
+Adds a group stage to the current pipeline.
+- by / _id (offcial MongoDB name represented by a pydantic alias), str | list[str] | set[str] : field or group of fields to group on
+- query, dict | None : Computed aggregated values (per group)
+
monggregate\pipeline.py
insert(index, stage)
+
+join(*, other, how='left', on=None, left_on=None, right_on=None)
+
+Adds a combination of stages, that together reproduce SQL joins. +This is a virtual and unofficial stage. It is not documented on MongoDB aggregation pipeline reference page. +As such, there is no Join class implementation in this package.
+- other, str : collection to join
+- how, 'left', 'right', 'inner' : type of join to be performed
+ 'left' preserve the left collection
+ 'right' preserve the right collection
+ 'inner' returns only documents from
+ the left collection that match
+ documents from the right collection
+
+- on, str|None=None: key to use to perform the join,
+ if the key name is the same in both collections
+- left_on, str|None=None: key to use on the left collection to perform the join.
+ Must be use with right_on.
+- right_on, str|None=None: key to use on the right collection to perform the join
+ Must be use with left_on.
+
monggregate\pipeline.py
limit(value)
+
+Adds a limit stage to the current pipeline.
+- value, int : the actual limit to apply.
+ limits the number of documents returned by the stage to
+ the provided value.
+
monggregate\pipeline.py
lookup(*, name, right=None, on=None, left_on=None, right_on=None)
+
+Adds a lookup stage to the current pipeline.
+- right / from (official MongoDB name), str : foreign collection
+- left_on / local_field (official MongoDB name)), str | None : field of the current collection to join on
+- right_on / foreign_field (official MongoDB name), str | None : field of the foreign collection to join on
+- let, dict | None : variables to be used in the inner pipeline
+- pipeline, list[dict] | None : pipeline to run on the foreign collection.
+- name / as, str : name of the field containing the matches from the foreign collection
+
+NOTE (pipeline and let attributes) : To reference variables in pipeline stages, use the "$$<variable>" syntax.
+
+The let variables can be accessed by the stages in the pipeline, including additional $lookup
+stages nested in the pipeline.
+
+* A $match stage requires the use of an $expr operator to access the variables.
+The $expr operator allows the use of aggregation expressions inside of the $match syntax.
+
+Starting in MongoDB 5.0, the $eq, $lt, $lte, $gt, and $gte comparison operators placed in an
+$expr operator can use an index on the from collection referenced in a $lookup stage. Limitations:
+
+ * Multikey indexes are not used.
+
+ * Indexes are not used for comparisons where the operand is an array or the operand type is undefined.
+
+ * Indexes are not used for comparisons with more than one field path operand.
+
+* Other (non-$match) stages in the pipeline do not require an
+$expr operator to access the variables.
+
monggregate\pipeline.py
match(query={}, expression=None, **kwargs)
+
+Adds a match stage to the current pipeline.
+- query, dict : a simple MQL query use to filter the documents.
+- expression, Expression : an aggregation expression used to filter the documents
+
NOTE : Use query if you're using a MQL query and expression if you're using aggregation expressions.
+ +monggregate\pipeline.py
out(collection, *, db=None)
+
+Adds an out stage to the current pipeline.
+- db, str|None : name of the db to output the collection. Defaults to current collection.
+- collection, str : name of the output collection
+
monggregate\pipeline.py
project(*, include=None, exclude=None, fields=None, projection={}, **kwargs)
+
+Adds a project stage to the current pipeline.
+- projection, dict | None : projection to be applied
+- fields, ProjectionArgs | None : fields to be kept or excluded (depending on include/exclude parameters when those are booleans)
+- include, ProjectionArgs| dict | bool | None : fields to be kept
+- exclude, ProjectionArgs | dict | bool | None : fields to be excluded
+
monggregate\pipeline.py
replace_root(path=None, *, document=None)
+
+Adds a replace_root stage to the current pipeline.
+- statement, dict : the statement generated during instantiation after parsing the other arguments
+- path_to_new_root, str|None : the path to the embedded document to be promoted
+- document, dict|None : document being created and to be set as the new root or expression
+
monggregate\pipeline.py
replace_with(path=None, *, document=None)
+
+Adds a replace_with stage to the current pipeline.
+- statement, dict : the statement generated during instantiation after parsing the other arguments
+- path_to_new_root, str|None : the path to the embedded document to be promoted
+- document, dict|None : document being created and to be set as the new root or expression
+
monggregate\pipeline.py
sample(value)
+
+Adds a sample stage to the current pipeline.
+- statement, dict : the statement generated after instantiation
+- value, int : positive integer representing the number of documents to be randomly picked. Defaults to 10.
+
monggregate\pipeline.py
search(path=None, query=None, *, operator_name='text', index='default', count=None, highlight=None, return_stored_source=False, score_details=False, **kwargs)
+
+Adds a search stage to the current pipeline +NOTE : if used, search has to be the first stage of the pipeline
+- path, str|list[str]|None : field to search in
+- query, str|list[str]|None : text to search for
+- index, str : name of the index to use for the search. Defaults to defaut
+- count, dict|None : document that specifies the count options for retrieving
+ a count of the results
+- highlight, dict|None : document that specifies the highlight options for
+ displaying search terms in their original context
+- return_stored_source, bool : Indicates whether to use the copy of the documents
+ in the Atlas Search index (with just a subset of the fields)
+ or to return the original full document (slower).
+ Defaults to False.
+ True => Use the copy
+ False => Do a lookup and return the original documents.
+- score_details, bool : Indicates whether to retrieve the detailed breakdown of the score for
+ the documents in the results. Defaults to False.
+ To view the details, you must use the $meta expression in the
+ $project stage.
+- operator_name, str : Name of the operator to search with. Use the compound operator to run a
+ compound (i.e query with multiple operators).
+- kwargs, Any : Operators specific options.
+ Includes (non-exhaustive):
+ - fuzzy, FuzzyOptions (controls fuzzy matching options)
+ - score, dict (controls scoring options)
+ - value, numeric|bool|date (for filtering)
+ - allow_analyzed_field, bool (controls index scanning)
+ - synonyms
+ - like, dict|list[dict] (allow looking for similar documents)
+
monggregate\pipeline.py
708 +709 +710 +711 +712 +713 +714 +715 +716 +717 +718 +719 +720 +721 +722 +723 +724 +725 +726 +727 +728 +729 +730 +731 +732 +733 +734 +735 +736 +737 +738 +739 +740 +741 +742 +743 +744 +745 +746 +747 +748 +749 +750 +751 +752 +753 +754 +755 +756 +757 +758 +759 +760 +761 +762 +763 +764 +765 +766 +767 +768 +769 +770 +771 |
|
search_compound()
+
+search_meta(path=None, query=None, *, operator_name='text', index='default', count=None, highlight=None, return_stored_source=False, score_details=False, **kwargs)
+
+Adds a searchMeta stage to the current pipeline +NOTE : if used, search has to be the first stage of the pipeline
+- path, str|list[str]|None : field to search in
+- query, str|list[str]|None : text to search for
+- index, str : name of the index to use for the search. Defaults to defaut
+- count, dict|None : document that specifies the count options for retrieving
+ a count of the results
+- highlight, dict|None : document that specifies the highlight options for
+ displaying search terms in their original context
+- return_stored_source, bool : Indicates whether to use the copy of the documents
+ in the Atlas Search index (with just a subset of the fields)
+ or to return the original full document (slower).
+ Defaults to False.
+ True => Use the copy
+ False => Do a lookup and return the original documents.
+- score_details, bool : Indicates whether to retrieve the detailed breakdown of the score for
+ the documents in the results. Defaults to False.
+ To view the details, you must use the $meta expression in the
+ $project stage.
+- operator_name, str : Name of the operator to search with. Use the compound operator to run a
+ compound (i.e query with multiple operators).
+- kwargs, Any : Operators specific options.
+ Includes (non-exhaustive):
+ - fuzzy, FuzzyOptions (controls fuzzy matching options)
+ - score, dict (controls scoring options)
+ - value, numeric|bool|date (for filtering)
+ - allow_analyzed_field, bool (controls index scanning)
+ - synonyms
+ - like, dict|list[dict] (allow looking for similar documents)
+
monggregate\pipeline.py
783 +784 +785 +786 +787 +788 +789 +790 +791 +792 +793 +794 +795 +796 +797 +798 +799 +800 +801 +802 +803 +804 +805 +806 +807 +808 +809 +810 +811 +812 +813 +814 +815 +816 +817 +818 +819 +820 +821 +822 +823 +824 +825 +826 +827 +828 +829 +830 +831 +832 +833 +834 +835 +836 +837 +838 +839 +840 +841 +842 +843 +844 +845 +846 |
|
set(document={}, **kwargs)
+
+Adds a set stage to the current pipeline.
+- statement, dict :
+- document, dict : new fields to be added
+
monggregate\pipeline.py
skip(value)
+
+Adds a skip stage to the current pipeline.
+- statement, dict : the statement generated after instantiation
+- value, int : positive integer representing the number of documents to be skipped.
+
monggregate\pipeline.py
sort(*, descending=None, ascending=None, by=None, query={}, **kwargs)
+
+Adds a sort stage to the current pipeline.
+- statement, dict : the statement generated after instantiation
+- query, dict : fields-sort order mapping. 1 for ascending order, -1 for descending order. Defaults to {}
+ if not provided, the query will be built from ascending and descending parameters.
+
+- ascending, set[str] | dict | None : fields to sort on ascending order on
+- descending, set[str] | dict | None : fields to sort on descending order on
+
NOTE : When trying to sort on several fields and opposite orders use query rather than using ascending and descending simunateously.
+WARNING : If using the ascending and descending parameters at the same time, the generated query will have the following form:
+>>> query = {
+ "ascending_field1" : 1,
+ ...
+ "ascending_fieldN" : 1,
+ "descending_field1" : -1,
+ ...
+ "descending_fieldN" : -1
+}
+
monggregate\pipeline.py
sort_by_count(by)
+
+Adds a sort_by_count stage to the current pipeline.
+- _statement, dict : the statement generated during the validation process
+- by, str : the key to group, sort and count on
+
monggregate\pipeline.py
to_statements()
+
+union_with(collection, pipeline=None)
+
+Adds a union_with stage to the current pipeline.
+- collection / coll, str : The collection or view whose pipeline results you wish to include in the result set
+- pipeline, list[dict] | Pipeline | None : An aggregation pipeline to apply to the specified coll.
+
monggregate\pipeline.py
unset(field=None, fields=None)
+
+Adds an unset stage to the current pipeline.
+- field, str|None: field to be removed
+- fields, list[str]|None, list of fields to be removed
+
monggregate\pipeline.py
unwind(path, include_array_index=None, always=False)
+
+Adds a unwind stage to the current pipeline.
+- path_to_array (path), str : path to an array field
+- include_array_index, str : name of a new field to hold the array index of the element
+ NOTE : The name cannot start with a dollar sign
+- always (preserve_null_and_empty_index), bool : whether to output documents for input documents where the path does not resolve to a valid array. Defaults to False
+
monggregate\pipeline.py
{"use strict";/*!
+ * escape-html
+ * Copyright(c) 2012-2013 TJ Holowaychuk
+ * Copyright(c) 2015 Andreas Lubbe
+ * Copyright(c) 2015 Tiancheng "Timothy" Gu
+ * MIT Licensed
+ */var _a=/["'&<>]/;Pn.exports=Aa;function Aa(e){var t=""+e,r=_a.exec(t);if(!r)return t;var o,n="",i=0,s=0;for(i=r.index;i