{
    "content": [
        {
            "type": "text",
            "text": "# MongoDB::ChangeStream (perldoc)\n\n## NAME\n\nMongoDB::ChangeStream - A stream providing update information for collections.\n\n## SYNOPSIS\n\n$stream = $collection->watch( $pipeline, $options );\nwhile(1) {\n# This inner loop will only iterate until there are no more\n# changes available.\nwhile (my $change = $stream->next) {\n...\n}\n}\n\n## DESCRIPTION\n\nThis class models change stream results as returned by the \"watch\" in MongoDB::Collection\nmethod.\n\n## Sections\n\n- **NAME**\n- **VERSION**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **STREAM METHODS**\n- **SEE ALSO**\n- **AUTHORS**\n- **COPYRIGHT AND LICENSE**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "MongoDB::ChangeStream",
        "section": "",
        "mode": "perldoc",
        "summary": "MongoDB::ChangeStream - A stream providing update information for collections.",
        "synopsis": "$stream = $collection->watch( $pipeline, $options );\nwhile(1) {\n# This inner loop will only iterate until there are no more\n# changes available.\nwhile (my $change = $stream->next) {\n...\n}\n}",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "VERSION",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 10,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "STREAM METHODS",
                "lines": 42,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 5,
                "subsections": []
            },
            {
                "name": "AUTHORS",
                "lines": 10,
                "subsections": []
            },
            {
                "name": "COPYRIGHT AND LICENSE",
                "lines": 6,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "MongoDB::ChangeStream - A stream providing update information for collections.\n",
                "subsections": []
            },
            "VERSION": {
                "content": "version v2.2.2\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "$stream = $collection->watch( $pipeline, $options );\nwhile(1) {\n\n# This inner loop will only iterate until there are no more\n# changes available.\nwhile (my $change = $stream->next) {\n...\n}\n}\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "This class models change stream results as returned by the \"watch\" in MongoDB::Collection\nmethod.\n",
                "subsections": []
            },
            "STREAM METHODS": {
                "content": "next\n$changestream = $collection->watch(...);\n$change = $changestream->next;\n\nWaits for the next change in the collection and returns it.\n\nNote: This method will wait for the amount of milliseconds passed as \"maxAwaitTimeMS\" to \"watch\"\nin MongoDB::Collection or the server's default wait-time. It will not wait indefinitely.\n\ngetresumetoken\nUsers can inspect the \"id\" on each \"ChangeDocument\" to use as a resume token. But since MongoDB\n4.2, \"aggregate\" and \"getMore\" responses also include a \"postBatchResumeToken\". Drivers use one\nor the other when automatically resuming.\n\nThis method retrieves the same resume token that would be used to automatically resume. Users\nintending to store the resume token should use this method to get the most up to date resume\ntoken.\n\nFor instance:\n\nif ($localchange) {\nprocesschange($localchange);\n}\n\neval {\nmy $changestream = $coll->watch([], { resumeAfter => $localresumetoken });\nwhile ( my $change = $changestream->next) {\n$localresumetoken = $changestream->getresumetoken;\n$localchange = $change;\nprocesschange($localchange);\n}\n};\nif (my $err = $@) {\n$log->error($err);\n}\n\nIn this case the current change is always persisted locally, including the resume token, such\nthat on restart the application can still process the change while ensuring that the change\nstream continues from the right logical time in the oplog. It is the application's\nresponsibility to ensure that \"processchange\" is idempotent, this design merely makes a\nreasonable effort to process each change at least once.\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "The Change Streams manual section <https://docs.mongodb.com/manual/changeStreams/>.\n\nThe Change Streams specification\n<https://github.com/mongodb/specifications/blob/master/source/change-streams.rst>.\n",
                "subsections": []
            },
            "AUTHORS": {
                "content": "*   David Golden <david@mongodb.com>\n\n*   Rassi <rassi@mongodb.com>\n\n*   Mike Friedman <friedo@friedo.com>\n\n*   Kristina Chodorow <k.chodorow@gmail.com>\n\n*   Florian Ragwitz <rafl@debian.org>\n",
                "subsections": []
            },
            "COPYRIGHT AND LICENSE": {
                "content": "This software is Copyright (c) 2020 by MongoDB, Inc.\n\nThis is free software, licensed under:\n\nThe Apache License, Version 2.0, January 2004\n",
                "subsections": []
            }
        }
    }
}