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
  • Returns
  • Examples
  1. Flow Builder
  2. Node Types
  3. Variable Nodes
  4. Special

Build Map

The Build Map node is used to create a new JSON / Object variable, with optional Key-Value pairs which should only be included if a certain condition is met.

This node is super helpful when we need to add keys based on certain conditions, such as existence in query params, etc so that we can build a dynamic object to query the database. Check the examples below for more inspiration.

Properties Panel

General

Field
Description
Required

Node name

true

Variable name

Name of the JSON variable you need to create

true

List of BuildMap objects

A list of buildmap objects where each object mentions the condition based on which to add a certain key/value pair in the final JSON object.

true

Returns

This node does not return any value, but sets a variable with your provided <name> in the flow context.

Examples

For example, if you have a Listing / Search API and would need to build a custom query object for the database (find or $match stage), you can use this node and provide the following list of buildmap objects -

[
    {
        "condition": {
            "$.request.queryParams.name": {
                "$neq": null
            }
        },
        "key": "name",
        "value": "$.request.queryParams.name"
    },
    {
        "condition": {
            "$.request.queryParams.jobTitle": {
                "$neq": null
            }
        },
        "key": "jobTitle",
        "value": "$.request.queryParams.jobTitle"
    },
    {
        "condition": {
            "$.request.queryParams.age": {
                "$ge": 10
            }
        },
        "key": "age",
        "value": "$.request.queryParams.age"
    }
]

The above buildmap objects list will iterate over each object to check if the condition is true or not, and if it is true, then will add the key-value pair to the following object.

Assuming above that name and jobTitle is not equal to null, but age is less than 10, this will result in a JSON variable as such -

{
    "name": "$.request.queryParams.name",
    "jobTitle": "$.request.queryParams.jobTitle"
}
PreviousSpecialNextSet Variable

Last updated 10 months ago

You can use with keys, values and conditions.

Checkout Node name
Magical Autocomplete