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. Variable Nodes
  4. Arrays

Get Array Item

PreviousExtend arrayNextLength of array

Last updated 10 months ago

Get Array Item node is designed to extract a specific item from an array based on its index. This node is particularly useful when you need to access a particular element within an array for further processing or output in your workflow.

Properties Panel

Field

Description

Required

Node name

true

Variable Name

The name of the variable where the extracted item will be stored

true

Item Index

The index of the item to be extracted from the array (0-based) -len(arr) <= i < len(arr)

true

Lookup Array

The array from which the item will be extracted

true

Usage

  1. Specify a variable name where the extracted item will be stored.

  2. Enter the index value of the item you want to extract (remember that array indices start at 0).

  3. Provide the lookup array from which the item will be extracted.

Returns

The node stores the extracted item in the specified variable. You can access this using Magical Autocomplete (e.g., $.variables.<variable_name>) in any node below this node.

Example

Let's say you have an array of user objects fetched from database using node and you want to extract the second user:

  1. Set Variable name to second_user

  2. Set Index value to 1 (remember, arrays are 0-indexed)

  3. Set Lookup array to $.listRecords.result (assuming you're using List Records node and it's name is listRecords)

This will store the second user object in the variable second_user. You can then use this in subsequent nodes by $.variables.second_user

Best Practices

  • Always ensure that the index value is within the bounds of the array. Attempting to access an out-of-bounds index may result in an error.

  • Negative Index are supported for extracting values from back but make sure it's within the size of lookup-array.

  • Remember that array indices start at 0, so the first item is at index 0, the second at index 1, and so on.

  • If you need to access the last item in an array of unknown length, you can use -1 as index value.

  • When working with potentially empty arrays, consider adding a condition to check the array length before attempting to extract an item.

List Records
Node Name