Mongo DB OID icon

Mongo DB OID

Find, insert and update documents in MongoDB

Overview

This node performs find and update operations on a MongoDB collection. It is useful for scenarios where you need to update existing documents in a MongoDB database based on a specific key, with options to upsert (insert if not found) and handle special data types like dates and ObjectIDs. For example, it can be used to update user profiles, product information, or any document where selective field updates are required.

Use Case Examples

  1. Updating user records in a MongoDB collection by matching user IDs and modifying specific fields like name and description.
  2. Replacing or updating documents with the option to insert new documents if no match is found (upsert).

Properties

Name Meaning
Collection The MongoDB collection where the documents will be updated.
Update Key The property name used to identify which documents to update, typically 'id' or '_id'.
Fields Comma-separated list of fields to include in the updated document.
Upsert Boolean flag to perform an insert if no documents match the update key.
Options Additional options for the update operation, including date fields, use of dot notation, and ObjectID fields.

Output

JSON

  • id - The unique identifier of the updated document.
    - Updated fields of the document as specified in the input.

Dependencies

  • MongoDB database connection with credentials

Troubleshooting

  • Common issues include invalid MongoDB connection credentials, incorrect collection names, or malformed query/update data.
  • Errors related to ObjectID conversion if the update key is '_id' but the value is not a valid ObjectID string.
  • Handling of date fields and ObjectID fields requires correct specification in options; otherwise, parsing errors may occur.

Links

Discussion