Cosmocloud Build Documentation
DocumentationTutorials
  • Welcome to Cosmocloud
  • Getting Started
    • 1. Organisations
    • 2. Projects
    • 3. Connect your Database
    • 4. Create Database Models
    • 5. Create APIs
    • 6. Testing Free Tier APIs
  • Free Tier
    • Connecting with MongoDB Data APIs
  • Templates
    • CRUD APIs
    • Entity Search APIs
    • Fetch / Upload Media APIs
  • Examples - How To?
    • Making an external API call
    • Reusable Flows - SubFlows
    • Creating Custom Error Responses
    • Flow Builder - Building Conditional Logics
    • Flow Builder - Utilising Loops
    • Creating Dynamic Queries
    • Accessing Auth Tokens in APIs
    • How to upload/download media in Object Storage
  • Resources
    • APIs
      • Checking Logs
    • SubFlows
    • Models
      • Building Models
    • Environments
      • Environment Tier Types
    • Secrets
      • Custom Secrets
    • Databases
    • Releases
    • Vector Search
      • Create a Vector Search Index
      • Edit a Vector Search Index
      • Delete a Vector Search Index
    • Document Search
      • Full Text Search
        • Concepts
          • Indexing in full-text search
          • Data processing using Analyzers
        • Create a Search Index
        • Creating a Custom Analyzer
        • Full Text Search FAQ
      • Vector Search
    • Object Storage
  • Flow Builder
    • Node Types
      • Trigger Nodes
        • HTTP Response
      • Conditional Nodes
        • If Else
        • If Else V2
        • Switch Case
      • Crypto Nodes
        • PBKDF2 Hmac Hash
      • Debug Node
      • Database Nodes
        • Delete One
        • Delete Many
        • Fetch By ID
        • Find One
        • Find Many
        • Insert One
        • Insert Many
        • List Records
        • Run Aggregation Pipeline
        • Update One
        • Update by ID
        • Update Many
      • External Nodes
        • Fire Events (SQS)
        • API Call
        • Delete storage objects
        • Execute SubFlow
        • Get Presigned URL
        • Post Presigned URL
        • Send EMAIL (SES)
        • Send SMS (SNS)
      • Loop Nodes
        • For loop
        • While loop
      • Variable Nodes
        • Arrays
          • Append array
          • Contains
          • Check array empty
          • Extend array
          • Get Array Item
          • Length of array
          • Reverse array
          • Sort array
        • Date and Time
          • Set current datetime
        • Strings
          • Append String
          • Concat Strings
          • Convert to String
          • Length of String
          • Slice String
          • Split String
          • String Operations
          • To Lower
          • To Upper
          • Trim String
        • Mathematical
          • Add Variable
          • Complex Math Expr
          • Decrement Variable
          • Divide Variable
          • Increment Variable
          • Multiply Variable
          • Subtract Variable
        • JSON
          • Build JSON Object
          • Merge JSON Objects
          • Object to String
          • Update JSON Object
        • Special
          • Build Map
          • Set Variable
          • Exists Check
    • Node name
    • CQL - Cosmocloud Query Language
      • Building Expressions
        • $abs
        • $add
        • $addDate
        • $arrayElemAt
        • $avg
        • $buildDateTime
        • $buildMap
        • $ceil
        • $cond
        • $divide
        • $floor
        • $getDay
        • $getHour
        • $getMinute
        • $getMonth
        • $getSecond
        • $getYear
        • $ifNull
        • $max
        • $min
        • $mod
        • $multiply
        • $pow
        • $subtract
        • $sqrt
      • Building Conditions
        • Compound Operators
          • $and
          • $or
        • Conditional Operators
          • $eq
          • $gt
          • $gte
          • $lt
          • $lte
          • $neq
      • Magical Autocomplete
  • Advanced Guide
    • Configuring Authentication
      • SSO Providers
        • AWS Cognito
      • Authentication Concepts
    • MongoDB Query Language
      • Limitations
    • Performance Considerations
      • Instant Deployments
  • User Management
  • Billing and Payments
    • Billing Portal
  • Help & Support
  • References
    • Change log
    • Available Cloud & Regions
Powered by GitBook
On this page
  • Properties Panel
  • Usage
  • Returns
  • Example
  • Best Practices
  1. Flow Builder
  2. Node Types
  3. Database Nodes

Update One

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.

Properties Panel

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

Usage

  1. Select the database collection you want to update.

  2. Define your query to match the desired record. For example: { "user_id": { "$eq": "12345" } }

  3. Specify the update snippet to apply the desired modifications. For example: { "$set": { "status": "active" } }

  4. Set the upsert option to true or false based on whether you want to create a new document if no match is found.

Returns

This node does not returns any value.

Example

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:

  1. Set Database Collection to users

  2. Set Query to { "email": { "$eq": "user@example.com" } }

  3. Set Update snippet to { "$set": { "status": "active", "last_login": "2024-07-22T10:00:00Z" } }

  4. 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.

Best Practices

  • 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.

PreviousRun Aggregation PipelineNextUpdate by ID

Last updated 9 months ago

Node Name