If you don’t see all the fields you expect to in the Replication Key field for you Mongo integration, the root cause may be insufficient permissions or a lack of field indexing.
Replication Key requirements
Stitch uses a field you define - called a Replication Key - to identify new and updated data for replication. For MongoDB integrations, Replication Key fields:
-
Must be a top-level field
-
Must exist in the root of the document
-
Must be single-field indexed
-
Must be one of the data types in the table below:
Data type | Available for | Notes |
DATETIME | All integrations | |
INTEGER | All integrations |
Includes |
TIMESTAMP | All integrations | |
FLOAT | MongoDB v1+ integrations | |
INT64 | MongoDB v1+ integrations | |
OBJECTID | MongoDB v1+ integrations | |
UUID | MongoDB v1+ integrations |
There are also some other considerations around Mongo Replication Keys, which you can read about in the Selecting & Changing Mongo Replication Keys guide.
Detect Fields for Use as Replication Keys
Stitch uses the listIndexes
command to find fields that you can use for Incremental Replication. This means:
- If the Stitch user doesn’t have permissions to run this command on a specified collection OR
- The field you want to use isn’t indexed
Stitch will only be able to display the _id
field in the Replication Key selection field.
If the collection is append-only, this may be perfectly fine.
If the collection isn’t append-only, another field may be needed. We recommend reviewing the Selecting & Changing Mongo Replication Keys guide for help selecting an appropriate Replication Key.
Next Steps
- Verify that the Stitch Mongo user has all the required permissions as outlined in the Mongo connection instructions.
- Verify that the field you want to use is indexed.
- Verify that the field you want to use as a Replication Key exists in the root of the document.
Note that it may take some time for Stitch to detect and process these changes after you’ve applied them. We recommend waiting for a replication cycle to complete before reaching out to support.
Contact Support
If you’ve done all of the above, a full replication cycle has completed, and the field still hasn’t shown up in the Replication Key field, please reach out to support.
Questions? Feedback?
Did this article help? If you have questions or feedback, feel free to submit a pull request with your suggestions, open an issue on GitHub, or reach out to us.