How to access fullDocument properties from a change stream?

Hello everyone,

I’m trying my hands on change streams for the first time.
I have something like this.'change', data => console.log(data));

But 1. is it possible to access the properties of fullDocument? and 2. how would I do this?

Additional parameters will be required to get the full document on updates.

For now I have something like:

async function getDocumentsFromChangeStream() {
    const changeStream =[], { fullDocument: 'updateLookup' }) as ChangeStream<Model>;

    changeStream.on('change', data => {
        if (data.operationType === 'insert') {
            return data.fullDocument;

So the use case would be to post some data (in my case testcases) to mongodb and then return each inserted document to running some tests with it.
this function should run insde a cron so that it listens every each x second on changes and returns the documents from the function. If you have any suggestions to it, it would be very welcome.

The full document will be available with inserts anyway, the { fullDocument: 'updateLookup' } is if you want the full document returned when updates are made too.

I would suggest that you keep the app running and processing the change stream full time rather than executing it periodically.

You will need to capture the resume token and persist it if you want the app to pick up from where it finished at program exit.