What is a function?

A function is a module of organized, reusable code that completes a specific action. Functions are used widely in computer programming because they are modular and reusable, and provide an output when given an input. Kidscodecs says a function is like a trusty dog that does the exact same trick (output) every time it is asked (input), which is adorable. đŸ¶

In Internal, a function specifies the underlying action that a component can perform. When components are added to a Space, whatever function is selected for that component will determine the action it performs. For instance, a button’s function can be wired to edit a user record or create a new user record.

Why use functions?

The University of Utah states four main reasons functions are ubiquitous in programming, which are as follows:

  • Functions allow code to be conceived as a series of steps, making the development process much easier. As opposed to trying to envision an entire program, it can be broken down into function blocks.

  • Functions allow code to be reused instead of created from scratch each time.

  • Functions allow developers to keep the variable namespace clean: Two functions can each produce a variable with the same name, but each variable only exists when the computer is running the specific function.

  • Functions allow programs to be tested and run in isolation from each other.

Database functions

Databases often provide their own set of functions to interact with the data:

MongoDB functions

The code for a function in MongoDB is a named JavaScript source file, meaning multiple JavaScript functions can be defined in a single function file. The functions are called directly from a client app, or from any defined services that can integrate and call functions.

When a function is called by name, the JavaScript function assigned to exports in the function’s source file is actually what’s being called.

A user function runs for a specific user of the application, and a system function has full access to MongoDB CRUD, aggregation APIs, and runs as the system user.

SQL Server Functions

SQL Server has many built-in functions including string functions, math functions, date functions, and advanced functions.

SQL Server functions are statements that execute a specific task, and are mostly used for saving time, rather than manually performing tasks within the database. There are a lot of them, and we won’t cover them all, but here’s a list of the most common functions used in SQL Server: W3 Schools SQL Server Functions List

MySQL Functions

MySQL is like SQL Server’s opensource cousin. Much of it remains the same, including functions, although queries are formatted differently. 

Same with SQL Server, there are many functions built into MySQL, and we certainly won’t cover them all. Fortunately, W3 Schools has already done that!

PostgreSQL Functions

PostgreSQL is an open source database released under the PostgreSQL License. All uses of PostgreSQL are free, including commercial use. Like MySQL and SQL Server, databases are communicated with via queries.

PostgreSQL also provides numerous functions for interacting with data via query.

Internal functions

Internal allows users to create functions that integrate and interact with any data source. Some functions, including insert, update, and delete, are automatically generated the second a user connects a data source.

Furthermore, Internal offers a function editor that can be used on top of any data source to write custom functions that perform user-specified commands. Functions can be mapped to components, which are drag-and-droppable dynamic elements that comprise a Space.

Learn more about functions—and how to configure them for each data source—in our documentation.


MongoDB: Atlas Functions

Software Testing Help: Difference between SQL, MySQL, and SQL Server

W3 Schools: SQL Server Functions

W3 Schools: MySQL Functions