Update One
Last updated
Last updated
Update One node is designed to modify a single specific record in a database based on a given query. It's useful when you need to update the information of a particular document that matches specified conditions.
This node is particularly valuable when you want to modify a unique record or when you're certain that only one record should be updated based on your criteria. If multiple records match the query, only the first matching record will be updated.
Select the database collection you want to update.
Define your query to match the desired record. For example: { "user_id": { "$eq": "12345" } }
Specify the update snippet to apply the desired modifications. For example: { "$set": { "status": "active" } }
Set the upsert option to true or false based on whether you want to create a new document if no match is found.
This node does not returns any value.
Let's say you want to update a user's status to active
based on their email address, and create the user if they don't exist:
Set Database Collection to users
Set Query to { "email": { "$eq": "user@example.com" } }
Set Update snippet to { "$set": { "status": "active", "last_login": "2024-07-22T10:00:00Z" } }
Set Upsert to true
This will either update an existing user's status and last login time, or create a new user with these details if no matching user is found.
Ensure your query is specific enough to target only the intended document.
Use atomic update operators (like $set, $inc, $push) to perform efficient updates without retrieving the entire document.
Be cautious when using upsert=true
, as it can create new documents. Make sure your update snippet includes all necessary fields for a new document.
Field
Description
Required
Default
Node name
true
-
Database collection
Database collection in which you want to update a specific document
true
-
Query Snippet
Query to identify which document needs to be modified
false
-
Update Snippet
Object which which will be used to replace or update current document
true
-
Upsert
Insert if document does not exist
false
false