MongoDB · New document — When a document is added to a MongoDB collection — checks a collection on a schedule. Each document newer than the newest it has seen starts a run, with the document's fields by their names.
Who can do this
Workspace Admins and Editors, on every plan.
Before you start
- A MongoDB connection in this workspace — see Connect MongoDB. Its user needs read on the collection.
Steps
- Open the workflow in the designer and open the trigger picker — Browse all triggers, or Change how it starts on an existing trigger.
- Select New document — MongoDB. Or type MongoDB in Search triggers.
- In Connection, choose your MongoDB connection, then the Database and the Collection.
- Optional: Newest by — leave it empty to go by
_id, or type a date field of your own, such as createdAt. Empty: by _id, which grows with time when MongoDB makes it. - Under Checks, choose Every 5 minutes or Every 15 minutes.
- Open the Output tab and select Fetch a sample. The newest document comes in, and Test run starts with it.
- Add the steps, test, then Publish.
What happens next
- The first check after publishing only notes the newest document. Documents already there never start a run — only documents added after you publish.
- Each new document starts one run, with each field by its name —
{{ trigger.customerEmail }}— and{{ trigger._id }}as text. - Up to 100 new documents start runs in one check, oldest first; the rest wait for the next check, in order.
- A check that finds nothing starts no run and costs nothing.
Good to know
- Every 5 minutes is for paid plans. On Free it checks every 15 minutes whatever is chosen.
- By
_idworks when MongoDB makes the_id. An ObjectId starts with the time it was made. If your application sets its own_ids — text, or numbers that do not grow — choose a date field under Newest by instead. - Changed documents do not start runs. Only documents newer than the newest seen.
- Changing the collection or Newest by and publishing starts again from the newest document then.
- Runs start in Production and count in the month's allowance.
If something goes wrong
| What you see | Why | What to do |
|---|---|---|
| Choose the database and the collection. | One of them is not chosen. | Choose both. |
| Not checking since 10:45 with MongoDB refused the user or password. … | The connection's sign-in stopped working. | Reconnect, then Check now. See When an app trigger stops checking. |
| New documents do not start runs | The _ids are your application's own and do not grow. |
Choose a date field under Newest by. |