CodeMash
  • 🚀Backend as a service
  • 🦄Roadmap
  • 🍕Release Notes
  • Installation
    • Managed Service
    • 🏗️AWS-CDK
    • 🏗️Azure
    • 🏗️Docker
    • 🏗️GC
    • 🏗️Terraform
  • dashboard
    • CodeMash Cloud
    • Project
    • Membership
      • Users
      • Roles
      • Policies
      • Triggers
      • Integrations
        • Apple
        • Azure
        • Facebook
        • Google
        • Twitter
      • Settings
    • Database
      • Collections
        • Schema
          • From Template
          • Structure
        • Tabs
        • Triggers
        • Indexes
        • Shared Forms
      • Taxonomies
        • Terms
        • Schema
        • Settings
      • Aggregation
      • Imports
      • Exports
      • Backups
    • Files
      • Integrations
        • CodeMash
        • S3 Bucket
    • Notifications
      • Push
        • Push Templates
        • Push Templates API
        • Push Notifications
        • Push Notifications API
        • Devices
        • Devices API
        • Integrations
          • Firebase
          • One Signal
          • Expo
      • Email
        • Email Templates
        • Emails
        • Integrations
          • AWS SES
          • Twilio Sendgrid
          • Mailgun
      • 🏗️Server events
      • 🏗️Sms
    • Payments
      • Integrations
        • Apple Pay
        • Google Pay
        • Stripe
        • Kevin.
        • Paysera
        • Decta
    • Scheduler
    • Logs & Monitoring
    • Code
      • Functions
        • Function Inputs
        • Function Templates
          • Node.js
          • Python
          • Ruby
          • Java
          • Go
          • .NET Core
      • CodeMash Functions
        • Google Functions
          • Google Calendar
          • Google Gmail
        • Microsoft Functions
          • Microsoft 365 Users
          • Microsoft 365 Calendar
        • Collection Find
        • Collection Update
        • Users Find
        • Image Resize
        • Html To Pdf
        • Word Document
        • Barcode
        • QR Code
        • Send Email
        • Send Notification
        • Email Reminder
        • Notification Reminder
      • Integrations
        • AWS Lambda
        • Google Cloud Functions
        • Azure Functions
  • Other Topics
    • Apple
      • Developer Portal
      • Bundle Identifier
      • Team ID
      • Service ID
      • Key ID
    • Triggers
    • Tokens Binding
      • Project Tokens
      • Initiator Tokens
      • Receiver Tokens
      • Request Tokens
      • Operation based tokens
      • Template Functions
    • Search parameters
      • Paging
      • Filter
      • Sort
      • Projection
    • data-models
    • Errors
  • SDK
    • Node.js
    • TypeScript
    • .NET
    • 🏗️Go Lang
    • 🏗️Flutter
    • 🏗️Swift
    • 🏗️Kotlin
  • CLI
    • 🏗️CodeMash CLI
  • API
    • Get Started
    • Prerequisites
    • How to test?
    • Cors
    • Project
    • Membership
      • Authentication
      • Users
    • Database
      • Collections
        • Aggregate
        • Change Responsibility
        • Count
        • Delete
        • Delete Many
        • Distinct
        • Find
        • Find One
        • Insert
        • Insert Many
        • References
        • Replace
        • Update
        • Update Many
      • Taxonomies
        • Find
    • Files
    • Code
    • Notifications
      • Push
      • Emails
      • Server Events
      • 🏗️Sms
    • Payments
    • Scheduler
    • Logs & Monitoring
Powered by GitBook
On this page
  • Specifics
  • Configuration
  • Update Query
  • External references

Was this helpful?

Edit on GitHub
  1. dashboard
  2. Code
  3. CodeMash Functions

Collection Update

Overview of update record function

This function allows you to quickly update a record inside the collection with a single button.

Specifics

Parameter

Description

Display name

Collection Update

Usage

Used on database collection record.

Can use from dashboard

Yes (from inside record's page)

Can use through API

Yes

Configuration

The function requires the following parameters.

Parameter

Description

Collection

Collection to which to attach this function to.

Display Name

Your custom display name for a function.

Update Query

MongoDB based update query to use when function is called.

Update Query

An update query is a BSON document that is similar to JSON but has some of its own additions. As it is a document, all query needs to be wrapped inside { ... }. The following shows some examples. Full documentation with all available operators and examples can be found in external resources at the end of a page.

General update syntax

The following is the general syntax of an update query.

{
   <operator1>: { <field1>: <value1>, ... },
   <operator2>: { <field2>: <value2>, ... },
   ...
}
  • Operator - a command to execute on its fields.

  • Field - field name (unique name of a field). To reach nested levels separate fields by . and use index to reach the specific document. An example of a nested field - details.0.status.

  • Value - an updated value of a field.

Examples

$set - sets the value of a field in a record.

{ $set: { first_name: 'John', 'details.0.is_active': true } }

$unset - removes the specified field from a record.

{ $unset: { quantity: "", instock: "" } }

$inc- increments the value of the field by the specified amount.

{ $inc: { quantity: 2, instock: -5 } }

External references

As CodeMash is using the MongoDB database internally, the following resources explain more of how to use an update query.

PreviousCollection FindNextUsers Find

Last updated 4 years ago

Was this helpful?

Full update command documentation
Possible update operators