Updates
This commit is contained in:
30
lowcoder/docs/connect-your-data/data-source-basics/README.md
Normal file
30
lowcoder/docs/connect-your-data/data-source-basics/README.md
Normal file
@@ -0,0 +1,30 @@
|
||||
# Data source basics
|
||||
|
||||
Data source is where you manage credentials and make connections to various popular databases such as PostgreSQL, MongoDB, Elasticsearch and all kinds of internal or third-party APIs.
|
||||
|
||||
Lowcoder stores your credentials securely and does not store any data from your requests or responses. It only serves as a proxy between client side and your data sources.
|
||||
|
||||
## Connect to a new data source
|
||||
|
||||
{% hint style="info" %}
|
||||
Check out IP allowlist and add Lowcoder IP addresses to your data source allowlist when needed.
|
||||
{% endhint %}
|
||||
|
||||
Follow the steps below:
|
||||
|
||||
1. Click **Data Sources** on Lowcoder homepage.
|
||||
2. Click **New data source** on the upper right. This permission is restricted to workspace admins and developers.
|
||||
3. Select the database or API type you need to connect.
|
||||
4. Fill out data source connection fields. See docs in Connect to databases and Connect to APIs for detailed tutorials.
|
||||
5. Click **Test connection** to check whether you can make a successful connection to data source based on current settings.
|
||||
6. Click **Save**.
|
||||
|
||||
You can also connect to a new data source when creating or editing queries in query library or query editor.
|
||||
|
||||
## Permissions
|
||||
|
||||
Only workspace admins and developers can view the **Data Sources** page and create new data sources.
|
||||
|
||||
For each data source, workspace admins and the creator can change its **Access Control**. Go to Lowcoder homepage > **Data Sources**, and click `···` > **Access Control**.
|
||||
|
||||
For more information about permissions for data sources, see Data sources.
|
||||
@@ -0,0 +1,27 @@
|
||||
# Configure IP allowlists
|
||||
|
||||
If your data source has firewall rules, it is vital to add IP addresses of Lowcoder to the allowlist before connection. Then you can connect to databases or APIs and create queries.
|
||||
|
||||
## Allow IP addresses of Lowcoder
|
||||
|
||||
Add the following IP addresses to your data source allowlist when needed:
|
||||
|
||||
```
|
||||
(US) !! IMPORTANT From 03.03.2024 we do not use US infrastructure !!
|
||||
185.122.165.50
|
||||
185.122.165.51
|
||||
185.122.165.52
|
||||
185.122.165.56
|
||||
|
||||
(GB)
|
||||
185.85.242.35
|
||||
185.85.242.36
|
||||
185.85.242.37
|
||||
|
||||
(DE)
|
||||
185.44.64.41
|
||||
185.44.64.42
|
||||
185.44.64.43
|
||||
185.44.64.44
|
||||
185.44.64.47
|
||||
```
|
||||
@@ -0,0 +1,98 @@
|
||||
# Data sources in Lowcoder
|
||||
|
||||
Data sources offer a wide range of capabilities to empower your Lowcoder applications and enable various use cases, from data storage and analytics to communication and automation.
|
||||
|
||||
As of 2023, you can use the following included Data sources:
|
||||
|
||||
**PostgreSQL** is an open-source relational database management system. It's highly versatile and can be used for various applications. With its ACID compliance and extensibility, it's a great choice for complex data structures and queries. Use cases include transactional and analytical applications across different industries.
|
||||
|
||||
**Microsoft SQL Server** is a relational database system developed by Microsoft. It's commonly employed in enterprise environments for mission-critical applications and business intelligence. What makes it exceptional is its robust security features, scalability, and seamless integration with Microsoft products.
|
||||
|
||||
**Oracle** is a powerful, enterprise-grade relational database. It's the go-to choice for large-scale applications that require high performance, reliability, and scalability. Some of the advanced features it offers include partitioning, clustering, and real application clusters.
|
||||
|
||||
**MariaDB** is an open-source relational database derived from MySQL. It's a versatile option, suitable for web applications, e-commerce, and general data storage. It combines MySQL compatibility with performance improvements and enhanced security.
|
||||
|
||||
**MySQL** is another open-source relational database management system known for its speed, reliability, and ease of use. It's widely used for web applications and data-driven websites.
|
||||
|
||||
**Elasticsearch** is a distributed, RESTful search and analytics engine. It's an exceptional choice for applications requiring full-text search, log and event data analysis, and real-time analytics. What makes it amazing is its ability to provide near-instant search results and scalability for large datasets.
|
||||
|
||||
**Redis** is an open-source, in-memory data structure store. It's ideal for tasks like caching, real-time analytics, and session management for web applications. It stands out for its high performance and low latency data access.
|
||||
|
||||
**MongoDB** is a NoSQL database designed for handling unstructured or semi-structured data. It's an excellent fit for use cases like content management systems, IoT applications, and mobile apps. MongoDB's flexible schema, scalability, and efficient handling of JSON data make it amazing.
|
||||
|
||||
**DynamoDB** is a managed NoSQL database service provided by AWS. It's particularly well-suited for serverless applications, gaming, and mobile apps. What sets it apart is its automatic scaling and high availability, all with minimal operational overhead.
|
||||
|
||||
**CouchDB** is a NoSQL database known for its simplicity and ease of use. It's great for document storage and other use cases where flexibility and straightforward data access are essential.
|
||||
|
||||
**ClickHouse** is an open-source columnar database management system designed for analytical processing. It's ideal for applications with large datasets that require fast analytics and reporting capabilities.
|
||||
|
||||
**Snowflake** is a cloud-based data warehousing platform that offers instant scaling and diverse data integration options. It's amazing for organizations that need a high-performance data warehousing solution without the hassles of traditional setups.
|
||||
|
||||
**Google Big Query** is a fully managed, serverless, and highly scalable multi-cloud data warehouse. It excels in fast data analytics, ad hoc queries, and real-time data analysis across large datasets.
|
||||
|
||||
**REST API** allows you to interact with web services using standard HTTP methods. It's widely used for integrating web applications with external services, retrieving data, and updating information.
|
||||
|
||||
**Open API Specification APIs** enable a GUI interface to access REST APIs. It's excellent for ensuring consistency and ease of use when working with APIs.
|
||||
|
||||
**SMTP** is used for sending and receiving email. It's essential for email communication in various applications, including transactional messages and notifications.
|
||||
|
||||
**Google Sheets** is a cloud-based spreadsheet software. It's amazing for collaborative data analysis, reporting, and sharing information in real-time.
|
||||
|
||||
**GraphQL** is the query language for APIs that provides more flexibility and efficiency compared to REST. It's great for fetching precisely the data you need and avoiding over-fetching, which is common in REST APIs.
|
||||
|
||||
**S3** Amazon S3 (Simple Storage Service) is a scalable object storage service that's perfect for storing and retrieving data, including backups, media files, and static website content.
|
||||
|
||||
**Google Cloud Storage** is a versatile and highly available object storage service. It's amazing for data storage and backups in Google Cloud Platform projects.
|
||||
|
||||
**n8n** the open-source workflow automation tool. It's excellent for building custom workflows and automating tasks across different applications and services.
|
||||
|
||||
**Firebase** is a platform for building mobile and web applications with a wide range of features, including real-time databases, authentication, and cloud functions. It's amazing for rapidly developing and deploying apps.
|
||||
|
||||
**WooCommerce** is a popular e-commerce plugin for WordPress. It's ideal for building online stores and managing product listings, customer orders, and payments.
|
||||
|
||||
**Open AI** provides APIs for various AI services, including natural language processing and machine learning. It's amazing for integrating advanced AI capabilities into your applications and services.
|
||||
|
||||
**Athena** Amazon Athena is an interactive query service that allows you to analyze data stored in Amazon S3 using standard SQL. It's excellent for ad-hoc data exploration and analysis.
|
||||
|
||||
**Asana** is a work management platform that helps teams organize and track tasks and projects. It's amazing for improving collaboration and productivity within organizations.
|
||||
|
||||
**Stripe** is a payment processing platform that simplifies online transactions and billing. It's great for e-commerce businesses and applications that require secure payment processing.
|
||||
|
||||
**CircleCI** is a continuous integration and continuous deployment (CI/CD) platform. It's amazing for automating software testing and deployment pipelines, ensuring code quality and reliability.
|
||||
|
||||
**Lambda** AWS Lambda is a serverless compute service. It's great for executing code in response to events and automating tasks without the need to manage server infrastructure.
|
||||
|
||||
**Front** is a customer communication platform that centralizes email, chat, and other customer interactions. It's amazing for enhancing customer support and collaboration within teams.
|
||||
|
||||
**GitHub** is a web-based platform for version control and collaborative software development. It's excellent for source code management and team collaboration on software projects.
|
||||
|
||||
**Gitlab** is a web-based DevOps lifecycle tool that provides version control, continuous integration, and more. It's amazing for managing the entire software development process.
|
||||
|
||||
**Hugging Face Endpoints:** Hugging Face provides endpoints for accessing state-of-the-art natural language processing models and tools. It's great for language understanding and generation tasks.
|
||||
|
||||
**Hugging Face Inference** provides APIs for running NLP models. It's amazing for integrating cutting-edge NLP capabilities into your applications.
|
||||
|
||||
**Jira** is a project and issue tracking tool by Atlassian. It's excellent for managing software development projects and workflows.
|
||||
|
||||
**OneSignal** is a push notification and in-app messaging platform. It's great for engaging and retaining users through timely notifications.
|
||||
|
||||
**SendGrid** is an email marketing and transactional email service. It's amazing for sending bulk emails and transactional messages.
|
||||
|
||||
**Shopify** is an e-commerce platform for building online stores. It's ideal for businesses looking to sell products online.
|
||||
|
||||
**Slack** is a messaging and collaboration platform for teams. It's great for real-time communication, file sharing, and project coordination.
|
||||
|
||||
**Supabase** is an open-source alternative to Firebase, offering a real-time database, authentication, and more. It's amazing for building web and mobile applications with dynamic, real-time features.
|
||||
|
||||
**Cloudinary** is a cloud-based media management platform. It's excellent for storing, optimizing, and delivering images and videos for web applications.
|
||||
|
||||
**Notion** is an all-in-one workspace for notes, tasks, wikis, and databases. It's amazing for knowledge management, project planning, and collaborative documentation.
|
||||
|
||||
**Datadog** is a monitoring and analytics platform for cloud-scale applications. It's great for gaining insights into the performance and health of your applications.
|
||||
|
||||
**Twilio** is a cloud communications platform that allows you to send messages, make voice calls, and more. It's amazing for adding communication features to your applications.
|
||||
|
||||
**Fauna** is a globally distributed, serverless database that's great for building modern applications with low-latency, real-time data access.
|
||||
|
||||
**D-ID** provides solutions for protecting privacy by anonymizing faces in images and videos. It's amazing for safeguarding sensitive data and ensuring GDPR compliance.
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
# APIs as Datasource
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
# Google Sheets
|
||||
|
||||
## Authentication
|
||||
|
||||
Follow the steps below to create a service account for your Google Cloud project and share your Google sheet through the \*\*\*\* service account key.
|
||||
|
||||
### Create a service account key
|
||||
|
||||
Follow the steps below:
|
||||
|
||||
1. Enable the [Google Sheets API](https://console.cloud.google.com/apis/library/sheets.googleapis.com) of your Google Cloud project.
|
||||
2. Select **APIs & Services** > **Credentials** from the left panel.
|
||||
3. Click **+ CREAT CREDENTIALS** > **Service account** to create a new service account.
|
||||
4. Get a service account key:
|
||||
1. Click the **Email** of the service account.
|
||||
2. Click **KEYS** > **ADD KEY** > **Create new key**.
|
||||
3. Select **JSON** as the key type.
|
||||
4. Click **CREATE** to download it.
|
||||
|
||||
{% hint style="success" %}
|
||||
Now the service account key, in a JSON format, is downloaded to your device. Make sure to keep it somewhere safe.
|
||||
{% endhint %}
|
||||
|
||||
### Share your Google sheet
|
||||
|
||||
Navigate back to to [Google Sheets](https://docs.google.com/spreadsheets), and follow the steps below to share your sheet through the \*\*\*\* service account key.
|
||||
|
||||
1. Open the JSON file of the key.
|
||||
2. Copy the value of `client_email`, which is an identity used for access management of your sheet.
|
||||
3. Click **Share** at the top right and paste the copied `client_email` value to add a member with access.
|
||||
4. Select **Editor** as the role and click **Send**.
|
||||
|
||||
{% hint style="success" %}
|
||||
When you see the notification **Access updated**, you have authorized this service account to edit your sheet.
|
||||
{% endhint %}
|
||||
|
||||
## Connect Google Sheets to Lowcoder
|
||||
|
||||
Follow the steps below:
|
||||
|
||||
1. Click **Data Sources** on Lowcoder homepage.
|
||||
2. Click **New Data Source** on the top right. Note that this permission is restricted to workspace admins and developers.
|
||||
3. Select **Database** > **Google Sheets** as the type.
|
||||
4. Set its name and paste the whole content in the JSON flie of the key to **Service Account**.
|
||||
5. Click **Save**, and you can check it in your data source library later.
|
||||
6. To access and manipulate data in your app, you can fill in the **Spreadsheet** id and **Sheet Name** in a query editor as follows.
|
||||
|
||||
The available methods are **Read Data**, **Append Row**, **Update Row**, and **Clear Row**.
|
||||
@@ -0,0 +1,62 @@
|
||||
# GraphQL
|
||||
|
||||
GraphQL query language allows the client to specify the structure of the requested data, and returns data from the server using the same structure. Such design ensures that only required data is retrieved, thus improving query efficiency.
|
||||
|
||||
## Connect GraphQL API to Lowcoder
|
||||
|
||||
Follow these steps to connect to GraphQL APIs.
|
||||
|
||||
1. Click **Data Sources** on the Lowcoder homepage.
|
||||
2. Click **New data source** on the upper right. This permission is restricted to workspace admins and developers.
|
||||
3. Select **APIs** > **GraphQL**.
|
||||
4. Configure general settings. At a minimum, input **Name** and the base **URL** of the API to connect to. **Headers** and **Parameters** are optional.
|
||||
5. Configure **Authentication Type**.
|
||||
6. Click **Save**.
|
||||
|
||||
You can also connect to a new GraphQL API data source when creating or editing queries in query library or query editor.
|
||||
|
||||
## Authentication type
|
||||
|
||||
By default, the authentication type is **None**. You can configure it as **Basic** or **Digest**, which require Username and Password. If you need other authentication methods, contact our customer service on the [homepage](https://lowcoder.dev).
|
||||
|
||||
The following is an example of connecting to [GitHub GraphQL API](https://docs.github.com/en/graphql). Set the authentication type to **None**. Then, input the required information into **Headers** to complete the authentication. The key is "Authorization" and the value is `"Bearer" + white space + YOUR_ACCESS_TOKEN`. See [Creating a personal access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token) for detailed information.
|
||||
|
||||
## SSL Cert Verification
|
||||
|
||||
For detailed information, see SSL Cert Verification.
|
||||
|
||||
## Forward cookies
|
||||
|
||||
For detailed information, see Forward cookies.
|
||||
|
||||
## Create a GraphQL query
|
||||
|
||||
You can create GraphQL queries in two ways:
|
||||
|
||||
* add a new data source and then create a query
|
||||
* create a query directly
|
||||
|
||||
Note that without creating a new data source, the GraphQL data source is not stored in your **Data Sources** and thus cannot be accessed to build other queries.
|
||||
|
||||
### Create a query with a new data source
|
||||
|
||||
Follow the steps to add a new GraphQL data source first and then create a query.
|
||||
|
||||
1. Connect GraphQL API to access to.
|
||||
2. In the query editor, click **+ New**.
|
||||
3. Select the added API in **Data source**.
|
||||
4. Write a query.
|
||||
5. Click ▶ **Run**.
|
||||
|
||||
For details about using GraphQL, reference [Introduction to GraphQL](https://graphql.org/learn/).
|
||||
|
||||
The following GraphQL query searches the latest 20 closed issues in the repository `octocat/Hello-World`, and returns the title, URL, and the first 5 labels of each issue.
|
||||
|
||||
### Create a query with predefined data source
|
||||
|
||||
Follow the steps to create a GraphQL query directly.
|
||||
|
||||
1. In the query editor, click **+ New**.
|
||||
2. Select **GraphQL Query** in Data sources. Lowcoder offers this built-in plain data source so that you can quickly create GraphQL queries without adding a new data source first.
|
||||
3. Enter URL, Query, Variables, Parameters, and fill in other fields if needed.
|
||||
4. Click ▶ **Run**.
|
||||
@@ -0,0 +1,58 @@
|
||||
# REST API
|
||||
|
||||
## Connect REST API to Lowcoder
|
||||
|
||||
Follow these steps to connect to REST APIs.
|
||||
|
||||
1. Click **Data Sources** on Lowcoder homepage.
|
||||
2. Click **New Data Source** on the upper right. This permission is restricted to workspace admins and developers.
|
||||
3. Select **APIs** > **REST API**.
|
||||
4. Configure general settings. At a minimum, input **Name** and the base **URL** of the API to connect to. **Headers** and **Parameters** are optional. These are all common parameters that consist of URL query prefixes.
|
||||
5. Configure **Authentication Type**.
|
||||
6. Click **Save**.
|
||||
|
||||
You can also connect to a new REST API data source when creating or editing queries in query library or query editor.
|
||||
|
||||
## Authentication type
|
||||
|
||||
The default authentication type is **None**. Other options are **Basic** and **Digest**, which require configuration of **Username** and **Password**.
|
||||
|
||||
If you need other customized authentication methods, contact our customer service on the [homepage](https://lowcoder.dev).
|
||||
|
||||
## SSL Cert Verification
|
||||
|
||||
In the advanced settings tab, you can configure SSL Cert Verification for your data sources. Three options are available: CA (Certificate Authority) Certificate, Self Signed Certificate, or Disabled. For security reasons, Lowcoder accepts APIs with CA certificates by default. For APIs without CA certificates, you can either select "Verify Self Signed Cert" and enter the self-signed certificate or disable the SSL Cert verification.
|
||||
|
||||
Note that for self-signed certificate, the information should be provided in .[PEM](https://en.wikipedia.org/wiki/Privacy-Enhanced\_Mail) (Privacy-Enhanced Mail) format. This certificate will be encrypted and stored securely in Lowcoder.
|
||||
|
||||
## Forward cookies
|
||||
|
||||
If you are self-hosting Lowcoder in your own domain, you can make REST API requests with cookies to existing services under that domain. You can either toggle the option "Forward all cookies" or specify certain cookies to forward in the text box. This feature can be helpful in cases where you use cookies to share common context (like identity info in JWT format) across different services.
|
||||
|
||||
## Create a REST API query
|
||||
|
||||
You can create REST API queries in two ways:
|
||||
|
||||
* add a new data source and then create a query
|
||||
* create a query directly
|
||||
|
||||
Note that without creating a new data source, the REST API data source is not stored in your **Data Sources** and thus cannot be accessed to build other queries.
|
||||
|
||||
### Create a query with a new data source
|
||||
|
||||
Follow the steps to add a new REST API data source first and then create a query.
|
||||
|
||||
1. Connect REST API to access to.
|
||||
2. In the query editor, click **+ New**.
|
||||
3. Select the added API in **Data source**.
|
||||
4. Enter URL, Headers, Parameters, and fill in other fields if needed.
|
||||
5. Click ▶ **Run**.
|
||||
|
||||
### Create a REST API query with predefined data source
|
||||
|
||||
Follow the steps to create a REST API query directly.
|
||||
|
||||
1. In the query editor, click **+ New**.
|
||||
2. Select **REST Query** in Data Sources. Lowcoder offers this built-in plain data source so that you can quickly create REST API queries without adding a new data source first.
|
||||
3. Enter URL, Query, Variables, Parameters, and fill in other fields if needed.
|
||||
4. Click ▶ **Run**.
|
||||
@@ -0,0 +1,2 @@
|
||||
# BigData & OLAP
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
# Big Query
|
||||
|
||||
Big Query is a fully managed cloud-based data warehouse offered by Google Cloud Platform that provides high-speed querying and interactive analysis of large datasets using SQL-like queries.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
* Get Big Query database connection parameters from the database owner.
|
||||
* Refer to IP allowlist to add IP addresses of Lowcoder to your allowlist (if needed).
|
||||
|
||||
## Connect to Big Query data source
|
||||
|
||||
Follow the steps below:
|
||||
|
||||
1. Create a new data source in two ways. Note that this permission is restricted to workspace admins and developers.
|
||||
* Navigate to the **Data Sources** tab on [Lowcoder Homepage](https://lowcoder.dev) and click **New data source**.
|
||||
* When creating a new query in the app editor, click **+ New** > **+ New data source**.
|
||||
2. Select **Database** > **Big Query** as the data source type.
|
||||
3. Set its name and service account.
|
||||
4. (Optional) Click **Test connection** to check whether the new data source is successfully connected.
|
||||
5. Click **Save**, and it will be saved to your data source library.
|
||||
@@ -0,0 +1,20 @@
|
||||
# ClickHouse
|
||||
|
||||
ClickHouse is an open-source column-oriented database management system designed for high-speed online analytical processing (OLAP) and data warehousing, capable of processing petabytes of data in real-time.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
* Get ClickHouse database connection parameters from the database owner.
|
||||
* Refer to IP allowlist to add IP addresses of Lowcoder to your allowlist (if needed).
|
||||
|
||||
## Connect to ClickHouse data source
|
||||
|
||||
Follow the steps below:
|
||||
|
||||
1. Create a new data source in two ways. Note that this permission is restricted to workspace admins and developers.
|
||||
* Navigate to the **Data Sources** tab on [Lowcoder Homepage](https://lowcoder.dev) and click **New data source**.
|
||||
* When creating a new query in the app editor, click **+ New** > **+ New data source**.
|
||||
2. Select **Database** > **ClickHouse** as the data source type.
|
||||
3. Set its name and configure general settings, including host, port, and database name. You can also set the user name and a password.
|
||||
4. (Optional) Click **Test connection** to check whether the new data source is successfully connected.
|
||||
5. Click **Save**, and it will be saved to your data source library.
|
||||
@@ -0,0 +1,20 @@
|
||||
# Elasticsearch
|
||||
|
||||
Elasticsearch is a highly scalable and distributed search and analytics engine designed to perform fast and complex searches on large volumes of data.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
* Get Microsoft SQL Server database connection parameters from the database owner.
|
||||
* Refer to IP allowlist to add IP addresses of Lowcoder to your allowlist (if needed).
|
||||
|
||||
## Connect to Elasticsearch data source
|
||||
|
||||
Follow the steps below:
|
||||
|
||||
1. Create a new data source in two ways. Note that this permission is restricted to workspace admins and developers.
|
||||
* Navigate to the **Data Sources** tab on [Lowcoder Homepage](https://lowcoder.dev) and click **New data source**.
|
||||
* When creating a new query in the app editor, click **+ New** > **+ New data source**.
|
||||
2. Select **Database** > **Elasticsearch** as the data source type.
|
||||
3. Set its name and configure general settings, including host, port, and database name. You can also set the user name and a password.
|
||||
4. (Optional) Click **Test connection** to check whether the new data source is successfully connected.
|
||||
5. Click **Save**, and it will be saved to your data source library.
|
||||
@@ -0,0 +1,20 @@
|
||||
# Snowflake
|
||||
|
||||
Snowflake is a cloud-based data warehousing platform that provides scalable and flexible solutions for storing, processing, and analyzing large volumes of data.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
* Get Snowflake database connection parameters from the database owner.
|
||||
* Refer to IP allowlist to add IP addresses of Lowcoder to your allowlist (if needed).
|
||||
|
||||
## Connect to Snowflake data source
|
||||
|
||||
Follow the steps below:
|
||||
|
||||
1. Create a new data source in two ways. Note that this permission is restricted to workspace admins and developers.
|
||||
* Navigate to the **Data Sources** tab on [Lowcoder Homepage](https://lowcoder.dev) and click **New data source**.
|
||||
* When creating a new query in the app editor, click **+ New** > **+ New data source**.
|
||||
2. Select **Database** > **Snowflake** as the data source type.
|
||||
3. Set its name and configure general settings, including account identifier, and database. You can also set schema, warehouse, user name, password, and so on.
|
||||
4. (Optional) Click **Test connection** to check whether the new data source is successfully connected.
|
||||
5. Click **Save**, and it will be saved to your data source library.
|
||||
@@ -0,0 +1,3 @@
|
||||
# File Storages
|
||||
|
||||
With Lowcoder you can connect to different File storage providers to upload and manage Your Files there.
|
||||
@@ -0,0 +1,99 @@
|
||||
# S3 File Storage
|
||||
|
||||
With the S3 Datasource Plugin, you can connect to your Amazon S3 Storage to upload and manage Files.
|
||||
|
||||
### Prepare Amazon S3 Buckets
|
||||
|
||||
<figure><img src="../../../.gitbook/assets/Amazon S3 Buckets.png" alt=""><figcaption><p>Create at least one Bucket in a Region.</p></figcaption></figure>
|
||||
|
||||
Next to Buckets, you need to create a User to configure Access Keys
|
||||
|
||||
<figure><img src="../../../.gitbook/assets/Amazon S3 User.png" alt=""><figcaption><p>Create a Amazon AWS User, give with a Policy the desired Access for your Buckets</p></figcaption></figure>
|
||||
|
||||
Now you can create the Access Keys
|
||||
|
||||
<figure><img src="../../../.gitbook/assets/Amazon S3 Access Key.png" alt=""><figcaption><p>The Access Keys are needed to connect to your S3 Buckets</p></figcaption></figure>
|
||||
|
||||
### Create a Datasource to Connect to your Bucket
|
||||
|
||||
To use Amazon S3, you need to connect to your Buckets.
|
||||
|
||||
<figure><img src="../../../.gitbook/assets/Data Plugin S3 Buckets.png" alt=""><figcaption><p>You need to have at least one Bucket as also your Access Key for S3</p></figcaption></figure>
|
||||
|
||||
The URL contains the Amazon AWS Region, in which you created the Buckets. This does not affect replica regions.
|
||||
|
||||
```
|
||||
https://s3.<your_aws_region>.amazonaws.com
|
||||
```
|
||||
|
||||
### Upload Files
|
||||
|
||||
With the help of the file upload component, you can now gather the data that you want to upload as Fle to your Bucket. There are two possible file types in general.
|
||||
|
||||
* Text based Files like JSON or CSV
|
||||
* Binary Files
|
||||
|
||||
{% hint style="info" %}
|
||||
Binary files are represented in the Browser as base64 encoding. However, after the transport to the S3 Bucket, they will be available as binary files.
|
||||
{% endhint %}
|
||||
|
||||
From the possible actions of the S3 Datasource Plugin you can choose "Upload file" and fill in the settings. 
|
||||
|
||||
<figure><img src="../../../.gitbook/assets/Data Plugin S3 File Upload.png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
### List Buckets and Files
|
||||
|
||||
Choose "List Buckets" to get a JSON List of your S3 Buckets.
|
||||
|
||||
<figure><img src="../../../.gitbook/assets/Data Plugin S3 Get Buckets.png" alt=""><figcaption><p>You can get all your S3 Buckets as Data List.</p></figcaption></figure>
|
||||
|
||||
```json
|
||||
// Response of "List buckets"
|
||||
[
|
||||
{
|
||||
"name": "lowcoder-documentation-bucket"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
With the name of the Bucket you can now request a list of all Files.
|
||||
|
||||
<figure><img src="../../../.gitbook/assets/Data Plugin S3 Get Files.png" alt=""><figcaption><p>Get a List of all Files in your Bucket as JSON</p></figcaption></figure>
|
||||
|
||||
```
|
||||
// Response of "List files"
|
||||
[
|
||||
{
|
||||
"name": "open_issues.json",
|
||||
"size": 247285,
|
||||
"lastModified": "2023-06-24T18:28:51.000Z",
|
||||
"signedUrl": "",
|
||||
"url": "https://s3.eu-central-1.amazonaws.com/lowcoder-documentation-bucket/open_issues.json"
|
||||
},
|
||||
{
|
||||
"name": "test.json",
|
||||
"size": 236646,
|
||||
"lastModified": "2023-06-24T18:17:13.000Z",
|
||||
"signedUrl": "",
|
||||
"url": "https://s3.eu-central-1.amazonaws.com/lowcoder-documentation-bucket/test.json"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
### Read / use Files
|
||||
|
||||
Based on Bucket & File name you can now request the Data of Files.
|
||||
|
||||
<figure><img src="../../../.gitbook/assets/Data Plugin S3 Get File.png" alt=""><figcaption><p>Get the file as JSON / Text or base64 encoded.</p></figcaption></figure>
|
||||
|
||||
An alternative way to access the File is via the secure Link (Signed URL). To get the "signed Link URLs" for your files, just use the "List files" method including the "Return signed url" checkbox.
|
||||
|
||||
<figure><img src="../../../.gitbook/assets/Data Plugin S3 Get Files with Signed Link.png" alt=""><figcaption><p>Get direct accessible Links of your files</p></figcaption></figure>
|
||||
|
||||
You can now use the URL of each file and for example, display it in the File viewer or with the [Image Component](../../../build-applications/app-editor/visual-components/image.md).
|
||||
|
||||
### Delete Files
|
||||
|
||||
You can use the Method "Delete file" to ... delete a single file from your Bucket.
|
||||
|
||||
<figure><img src="../../../.gitbook/assets/Data Plugin S3 File Delete.png" alt=""><figcaption><p>You can delete single files from your Bucket</p></figcaption></figure>
|
||||
@@ -0,0 +1,2 @@
|
||||
# InMemory Databases
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
# Redis
|
||||
|
||||
Redis (Remote Dictionary Server) is an open-source in-memory data structure store. Due to the nature of being fast, scalable, and highly available, Redis is a popular choice for applications that require real-time data processing, high throughput, and low latency.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
* Get Redis database connection parameters from the database owner.
|
||||
* Refer to IP allowlist to add IP addresses of Lowcoder to your allowlist (if needed).
|
||||
|
||||
## Connect to Redis data source
|
||||
|
||||
Follow the steps below:
|
||||
|
||||
1. Create a new data source in two ways. Note that this permission is restricted to workspace admins and developers.
|
||||
* Navigate to the **Data Sources** tab on [Lowcoder Homepage](https://lowcoder.dev) and click **New data source**.
|
||||
* When creating a new query in the app editor, click **+ New** > **+ New data source**.
|
||||
2. Select **Database** > **Redis** as the data source type.
|
||||
3. Set its name and configure the parameters according to your **Connection Type**:
|
||||
* **Regular**: Host, port, database name (required); user name, password (optional)
|
||||
* **URI**: URI 
|
||||
4. (Optional) Click **Test connection** to check whether the new data source is successfully connected.
|
||||
5. Click **Save**, and it will be saved to your data source library.
|
||||
@@ -0,0 +1,2 @@
|
||||
# NoSQL Databases
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
# CouchDB
|
||||
|
||||
CouchDB is an open-source NoSQL document-oriented database management system that provides easy-to-use web-based interfaces for data storage, retrieval, and indexing, as well as built-in synchronization and replication capabilities.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
* Get CouchDB database connection parameters from the database owner.
|
||||
* Refer to IP allowlist to add IP addresses of Lowcoder to your allowlist (if needed).
|
||||
|
||||
## Connect to CouchDB data source
|
||||
|
||||
Follow the steps below:
|
||||
|
||||
1. Create a new data source in two ways. Note that this permission is restricted to workspace admins and developers.
|
||||
* Navigate to the **Data Sources** tab on [Lowcoder Homepage](https://lowcoder.dev) and click **New data source**.
|
||||
* When creating a new query in the app editor, click **+ New** > **+ New data source**.
|
||||
2. Select **Database** > **CouchDB** as the data source type.
|
||||
3. Set its name and configure the server URL. You can also set the user name and a password.
|
||||
4. (Optional) Click **Test connection** to check whether the new data source is successfully connected.
|
||||
5. Click **Save**, and it will be saved to your data source library.
|
||||
@@ -0,0 +1,20 @@
|
||||
# DynamoDB
|
||||
|
||||
DynamoDB is a fully managed NoSQL database service offered by Amazon Web Services (AWS) that provides fast and predictable performance with seamless scalability, making it ideal for applications with high scalability requirements.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
* Get DynamoDB database connection parameters from the database owner.
|
||||
* Refer to IP allowlist to add IP addresses of Lowcoder to your allowlist (if needed).
|
||||
|
||||
## Connect to DynamoDB data source
|
||||
|
||||
Follow the steps below:
|
||||
|
||||
1. Create a new data source in two ways. Note that this permission is restricted to workspace admins and developers.
|
||||
* Navigate to the **Data Sources** tab on [Lowcoder Homepage](https://lowcoder.dev) and click **New data source**.
|
||||
* When creating a new query in the app editor, click **+ New** > **+ New data source**.
|
||||
2. Select **Database** > **DynamoDB** as the data source type.
|
||||
3. Set its name and configure general settings, including access key ID, secret key. You can also set endpoint URL and region.
|
||||
4. (Optional) Click **Test connection** to check whether the new data source is successfully connected.
|
||||
5. Click **Save**, and it will be saved to your data source library.
|
||||
@@ -0,0 +1,22 @@
|
||||
# MongoDB
|
||||
|
||||
MongoDB is a broadly used NoSQL database system that stores data in JSON-like documents with dynamic schemas and handles both unstructured and semi-structured data. By offering high performance, scalability, and ease of use, MongoDB is a versatile and robust solution for a wide range of use cases.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
* Get MongoDB database connection parameters from the database owner.
|
||||
* Refer to IP allowlist to add IP addresses of Lowcoder to your allowlist (if needed).
|
||||
|
||||
## Connect to MongoDB data source
|
||||
|
||||
Follow the steps below:
|
||||
|
||||
1. Create a new data source in two ways. Note that this permission is restricted to workspace admins and developers.
|
||||
* Navigate to the **Data Sources** tab on [Lowcoder Homepage](https://lowcoder.dev) and click **New data source**.
|
||||
* When creating a new query in the app editor, click **+ New** > **+ New data source**.
|
||||
2. Select **Database** > **MongoDB** as the data source type.
|
||||
3. Set its name and configure the parameters according to your **Connection Type**:
|
||||
* **Regular**: Host, port, database name (required); user name, password (optional)
|
||||
* **URI**: URI
|
||||
4. (Optional) Click **Test connection** to check whether the new data source is successfully connected.
|
||||
5. Click **Save**, and it will be saved to your data source library.
|
||||
@@ -0,0 +1,2 @@
|
||||
# SQL Databases
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
# MariaDB
|
||||
|
||||
MariaDB is a popular open-source relational database management system that offers high performance, scalability, and security features for businesses and organizations of all sizes.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
* Get MariaDB database connection parameters from the database owner.
|
||||
* Refer to IP allowlist to add IP addresses of Lowcoder to your allowlist (if needed).
|
||||
|
||||
## Connect to MariaDB data source
|
||||
|
||||
Follow the steps below:
|
||||
|
||||
1. Create a new data source in two ways. Note that this permission is restricted to workspace admins and developers.
|
||||
* Navigate to the **Data Sources** tab on [Lowcoder Homepage](https://lowcoder.dev) and click **New data source**.
|
||||
* When creating a new query in the app editor, click **+ New** > **+ New data source**.
|
||||
2. Select **Database** > **MariaDB** as the data source type.
|
||||
3. Set its name and configure general settings, including host, port, and database name. You can also set the user name and a password.
|
||||
4. (Optional) Click **Test connection** to check whether the new data source is successfully connected.
|
||||
5. Click **Save**, and it will be saved to your data source library.
|
||||
@@ -0,0 +1,20 @@
|
||||
# Microsoft SQL Server
|
||||
|
||||
Microsoft SQL Server is a relational database management system (RDBMS), offering a comprehensive platform for storing, managing, and retrieving data from various sources.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
* Get Microsoft SQL Server database connection parameters from the database owner.
|
||||
* Refer to IP allowlist to add IP addresses of Lowcoder to your allowlist (if needed).
|
||||
|
||||
## Connect to Microsoft SQL Server data source
|
||||
|
||||
Follow the steps below:
|
||||
|
||||
1. Create a new data source in two ways. Note that this permission is restricted to workspace admins and developers.
|
||||
* Navigate to the **Data Sources** tab on [Lowcoder Homepage](https://lowcoder.dev) and click **New data source**.
|
||||
* When creating a new query in the app editor, click **+ New** > **+ New data source**.
|
||||
2. Select **Database** > **Microsoft SQL Server** as the data source type.
|
||||
3. Set its name and configure general settings, including host, port, and database name. You can also set the user name and a password.
|
||||
4. (Optional) Click **Test connection** to check whether the new data source is successfully connected.
|
||||
5. Click **Save**, and it will be saved to your data source library.
|
||||
@@ -0,0 +1,24 @@
|
||||
# MySQL
|
||||
|
||||
MySQL is a popular relational database management system (RDBMS) and is widely used in various industries due to its scalability, flexibility, and ease of use.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
* Get MySQL database connection parameters from the database owner.
|
||||
* Refer to IP allowlist to add IP addresses of Lowcoder to your allowlist (if needed).
|
||||
|
||||
## Connect to MySQL data source
|
||||
|
||||
Follow the steps below:
|
||||
|
||||
1. Create a new data source in two ways. Note that this permission is restricted to workspace admins and developers.
|
||||
* Navigate to the **Data Sources** tab on [Lowcoder Homepage](https://lowcoder.dev) and click **New data source**.
|
||||
* When creating a new query in the app editor, click **+ New** > **+ New data source**.
|
||||
2. Select **Database** > **MySQL** as the data source type.
|
||||
3. Set its name and configure general settings, including host, port, and database name. You can also set the user name and a password.
|
||||
4. (Optional) Click **Test connection** to check whether the new data source is successfully connected.
|
||||
5. Click **Save**, and it will be saved to your data source library.
|
||||
|
||||
## Query a MySQL data source
|
||||
|
||||
Create `query1` and select the recently created data source. Insert a query and then click ▶ **Run**.
|
||||
@@ -0,0 +1,20 @@
|
||||
# Oracle
|
||||
|
||||
Oracle is a leading provider of enterprise software and database management systems, offering a wide range of solutions for businesses of all sizes.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
* Get Oracle database connection parameters from the database owner.
|
||||
* Refer to IP allowlist to add IP addresses of Lowcoder to your allowlist (if needed).
|
||||
|
||||
## Connect to Oracle data source
|
||||
|
||||
Follow the steps below:
|
||||
|
||||
1. Create a new data source in two ways. Note that this permission is restricted to workspace admins and developers.
|
||||
* Navigate to the **Data Sources** tab on [Lowcoder Homepage](https://lowcoder.dev) and click **New data source**.
|
||||
* When creating a new query in the app editor, click **+ New** > **+ New data source**.
|
||||
2. Select **Database** > **Oracle** as the data source type.
|
||||
3. Set its name and configure general settings, including host, port, and service name. You can also set the user name and a password.
|
||||
4. (Optional) Click **Test connection** to check whether the new data source is successfully connected.
|
||||
5. Click **Save**, and it will be saved to your data source library.
|
||||
@@ -0,0 +1,20 @@
|
||||
# PostgreSQL
|
||||
|
||||
PostgreSQL is a powerful open-source relational database management system (RDBMS), renowned for stability, scalability, and robustness. It is an ideal choice for applications that require data consistency and reliability.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
* Get PostgreSQL database connection parameters from the database owner.
|
||||
* Refer to IP allowlist to add IP addresses of Lowcoder to your allowlist (if needed).
|
||||
|
||||
## Connect to PostgreSQL data source
|
||||
|
||||
Follow the steps below:
|
||||
|
||||
1. Create a new data source in two ways. Note that this permission is restricted to workspace admins and developers.
|
||||
* Navigate to the **Data Sources** tab on [Lowcoder Homepage](https://lowcoder.dev) and click **New data source**.
|
||||
* When creating a new query in the app editor, click **+ New** > **+ New data source**.
|
||||
2. Select **Database** > **PostgreSQL** as the data source type.
|
||||
3. Set its name and configure general settings, including host, port, and database name. You can also set the user name and a password.
|
||||
4. (Optional) Click **Test connection** to check whether the new data source is successfully connected.
|
||||
5. Click **Save**, and it will be saved to your data source library.
|
||||
@@ -0,0 +1,110 @@
|
||||
---
|
||||
description: Realtime Data Updates in Lowcoder
|
||||
---
|
||||
|
||||
# Websocket Datasource
|
||||
|
||||
In the digital age, speed and immediacy are a key success factor. That's why we believe our **WebSocket Datasource** is a gread addition. But why is this such a game-changer?
|
||||
|
||||
* **Instant Updates:** Unlike traditional methods where you'd need to refresh or poll for new data via APIs, WebSockets push updates to the Browser of the Application Users the moment they happen. Imagine viewing a dashboard and watching data points, charts, and metrics update in real-time without additional API Call logic.
|
||||
* **Enhanced Collaboration:** WebSockets don't just update data; they transform collaboration. When multiple users are viewing the same content, any change made by one user can be instantly seen by others. This means teams can work together seamlessly, making decisions based on real-time insights. This is possible thanks to the broadcast function we introduced.
|
||||
* **Reduced Latency:** With WebSockets, the lag between sending a request and receiving a response is drastically reduced. This ensures that your apps feel snappier and more responsive, enhancing user experience.
|
||||
* **Endless Possibilities:** From live chat applications to real-time gaming, tracking, and monitoring systems, the applications of WebSockets are vast. With our WebSocket Datasource, you're not just staying updated; you're unlocking a world of real-time possibilities for your apps.
|
||||
|
||||
### Using a WebSocket as Datasource.
|
||||
|
||||
First, select "Stream Query" as a new Query from the available Datasources. Stream Query is available from Lowcoder v2.1.0.
|
||||
|
||||
<figure><img src="../../.gitbook/assets/Screenshot 2023-10-24 at 13.33.13.png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
#### Connect to a WebSocket Server
|
||||
|
||||
As URL enter the WebSocket Server address ws:// (without) and wss:// (with SSL secured connection). From the moment you run this query, Lowcoder tries to establish a connection to the WebSocket Server. If successful, the specialty of WebSocket connections is, that they remain active and open till you disconnect the Dataquery / Lowcoder App.
|
||||
|
||||
|
||||
|
||||
{% hint style="info" %}
|
||||
[https://www.piesocket.com](https://www.piesocket.com/) is a service that you can use to establish and use WebSocket Servers as a Service.
|
||||
{% endhint %}
|
||||
|
||||
{% hint style="warning" %}
|
||||
Each time a message arrives in the open connection, the Lowcoder Query will fire the event "success", so you can bind an Event-Handler to process these messages.
|
||||
{% endhint %}
|
||||
|
||||
<figure><img src="../../.gitbook/assets/Screenshot 2023-10-24 at 13.33.02.png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
```
|
||||
// for example wss://ws.kraken.com
|
||||
```
|
||||
|
||||
#### Receive and Broadcast messages 
|
||||
|
||||
Now the connection is made and depending on the channel you may already receive data. Quite often it is however the case, that a Client needs to subscribe to a certain topic or room. To do so, but also simply to broadcast a message into the connection, you can use the new function broadcast(); This is a function of the WebSocket Datasource / Stream Query.
|
||||
|
||||
Here is an example as JavaScript, which is called as soon as the Stream Query is connected successfully to the WebSocket Server and listens in the channel.
|
||||
|
||||
Messages arrive and are broadcasted as JSON.
|
||||
|
||||
<figure><img src="../../.gitbook/assets/Screenshot 2023-10-24 at 13.41.50.png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
```javascript
|
||||
// for example:
|
||||
|
||||
krakenStockTicker.broadcast({
|
||||
"event": "subscribe",
|
||||
"pair": [
|
||||
"EUR/USD"
|
||||
],
|
||||
"subscription": {
|
||||
"name": "ohlc"
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
#### Processing incoming Messages
|
||||
|
||||
We can now bind the messages that are incoming and trigger the "onSuccess" of the Stream Query to a Temporary state. This is exemplary and you may want to integrate it differently.
|
||||
|
||||
<figure><img src="../../.gitbook/assets/Screenshot 2023-10-24 at 13.46.39.png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
We use the "Success" trigger of the Stream Query and set a Temporary State with the value. In the special case of Kraken Websocket, we want to skip all "heartbeat messages", so we only set Temporary State, if there are payload data in the current message.
|
||||
|
||||
#### Collecting Messages
|
||||
|
||||
It may be useful in your application scenario to collect Messages, for example, to show a sliding Window Chart like this OHLC diagram of our example. To do so, we create for example an Array, which is available for the whole app.
|
||||
|
||||
```javascript
|
||||
window.krakenStockTickerData = [];
|
||||
```
|
||||
|
||||
<figure><img src="../../.gitbook/assets/Screenshot 2023-10-24 at 13.52.10.png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
Now we can bind a Javascript processing for each incoming message to the "Success" Trigger of the Stream Query and bind our chart to this data-array.
|
||||
|
||||
```javascript
|
||||
// we take the string value of the Websocket Message and build an Array
|
||||
const currentRawTickerData = currentTickerData.value.split(',');
|
||||
// based on the array we can extract now the data we want and formulate an JSON Object
|
||||
const currentCleanTickerData = {
|
||||
"time" : new Date(currentRawTickerData[0].substr(0,10) * 1000).toISOString().substr(11, 8),
|
||||
"duration" : new Date(currentRawTickerData[1].substr(0,10) * 1000).toISOString().substr(11, 8),
|
||||
"open" : currentRawTickerData[2],
|
||||
"high" : currentRawTickerData[3],
|
||||
"low" : currentRawTickerData[4],
|
||||
"close" : currentRawTickerData[5],
|
||||
"weighted_volume" : currentRawTickerData[6],
|
||||
"accumulated_volume" : currentRawTickerData[7],
|
||||
"trades" : currentRawTickerData[8]
|
||||
}
|
||||
// we push the new Object into the array, krakenStockTickerData
|
||||
window.krakenStockTickerData.push(currentCleanTickerData);
|
||||
// and we make sure that old data is deleted, so the array won't get too big
|
||||
while (window.krakenStockTickerData.length > 30) {
|
||||
window.krakenStockTickerData.shift();
|
||||
}
|
||||
// Here we set a value in a temporary state, so the eCharts would update their visualization
|
||||
// (the binding to the array on the window-object does not release a trigger for eCharts to re-render)
|
||||
clockTickerData.setValue(currentCleanTickerData.time);
|
||||
```
|
||||
|
||||
<figure><img src="../../.gitbook/assets/Screenshot 2023-10-24 at 13.56.32.png" alt=""><figcaption></figcaption></figure>
|
||||
93
lowcoder/docs/connect-your-data/query-basics/README.md
Normal file
93
lowcoder/docs/connect-your-data/query-basics/README.md
Normal file
@@ -0,0 +1,93 @@
|
||||
# Query basics
|
||||
|
||||
If there is a special case handling, you can specify it additionally for the individual Event HandlerQueries support reading data from or writing data to your data sources. You can use Data Queries for all kinds of Data Sources, like Databases, Stream Data Sources, or classic Restful APIs. You can create queries while editing an app or in the query library. 
|
||||
|
||||
All Data Queries in Lowcoder will always return JSON Data. When you call your Database, the result will get transformed into a JSON response for example. This is very useful to have ease of use for the data in all later places in Lowcoder without the need for a Data Serialization between Formats.
|
||||
|
||||
## Connect to a data source
|
||||
|
||||
You can connect to a data source that was already in your data source library or create a new one. For detailed information, see [Data sources in Lowcoder](../data-sources-in-lowcoder/).
|
||||
|
||||
## Create a query
|
||||
|
||||
The UI of query editor varies when you choose different types of data sources. Below is an example of a connection to a PostgreSQL database and a corresponding statement.
|
||||
|
||||
<figure><img src="../../.gitbook/assets/App Editor Database Query SQL.png" alt=""><figcaption><p>A Data Query to a Postgres Database</p></figcaption></figure>
|
||||
|
||||
The SQL Mode is suitable for everyone who queries the Database and for proficient Developers who are very fluent in SQL Language and their used Database specialties.
|
||||
|
||||
<figure><img src="../../.gitbook/assets/App Editor Database Query GUI.png" alt=""><figcaption><p>For many Databases there is a visual GUI Mode to execute prepared statements on the Database.</p></figcaption></figure>
|
||||
|
||||
Lowcoder also offers a GUI Mode for Write-Operations on the Database, such as INSERT, UPDATE, and DELETE. This helps you to ease the Binding of user-made changes of Data in your App, back to the Databases.
|
||||
|
||||
### Metadata
|
||||
|
||||
You can view the metadata of databases such as PostgreSQL, MongoDB, and MySQL. Click Metadata, and the database tables and their fields are displayed in a tree structure. Metadata is useful for writing queries, and it enables auto-suggestion while you type. It can also help you understand the Structure of the Database and its tables for a connected Database.
|
||||
|
||||
### Dynamic Queries and Data Binding
|
||||
|
||||
Lowcoder evaluates your query statement with JavaScript code inside `{{ }}` in real-time, and the result is displayed below in a floating box, so you can use it to check the correctness of the query statement.
|
||||
|
||||
## Trigger a query when:...
|
||||
|
||||
Lowcoder triggers your queries in two modes: it runs automatically when "inputs change or on page load" or manually (and so invoked in other event handlers for example). 
|
||||
|
||||
### Inputs change or on page load
|
||||
|
||||
Queries set to this mode automatically run when dependent inputs change or on page load. For example, the query result of `select * from users where customer_id = {{input.value}}` updates immediately when `input.value` changes. \*\*\*\* This mode to run a query is recommended for queries reading data from data sources.
|
||||
|
||||
{% hint style="warning" %}
|
||||
Consider carefully when to trigger a query. Data Queries that may take longer to respond may block the application visuals from loading properly and displaying your data. 
|
||||
{% endhint %}
|
||||
|
||||
### Manually invoked
|
||||
|
||||
For this mode of queries, they run only with your manual trigger, such as a button or link click. You need to specify an event handler to trigger the query. This mode is recommended for queries writing data to data sources, because you may need to confirm that the input is complete and error-free before running it.
|
||||
|
||||
{% hint style="info" %}
|
||||
**How to choose a query's trigger mode?**
|
||||
|
||||
In most cases, queries reading data, like **select** operations, can be set to the former mode, and those writing data, like **create**/**delete**/**update** operations, run the latter way.
|
||||
|
||||
When Lowcoder detects your query statement switches from reading to writing data, the trigger mode switches to **Manually invoked** automatically, but not the other way around.
|
||||
{% endhint %}
|
||||
|
||||
{% hint style="info" %}
|
||||
Sometimes, you can also have the need to call a Data Query as an outcome or after the response of another Data Query to merge data responses, for example. You can use [Event-Handlers](../../build-applications/app-interaction/event-handlers.md) of Data Queries or the so called [Data Responder](../../business-logic-in-apps/write-javascript/data-responder.md) then. The first query may be triggered "on Inputs change or on page load" and following queries will then use the trigger "manually invoked".
|
||||
{% endhint %}
|
||||
|
||||
## Response-Event Handler
|
||||
|
||||
As soon as the Response processing (and parsing) of a Data Query is done, you can use Event Handlers as a trigger for further actions. There are onSuccess and onError Triggers. You also can combine multiple Event Handlers.
|
||||
|
||||
### onSuccess Handler
|
||||
|
||||
The `onSuccess` handler is designed to execute specific actions after a data query has successfully completed. This mechanism is essential for initiating subsequent operations, such as running JavaScript queries or other subsequent queries that may need the Response of a initial Data Query.
|
||||
|
||||
**Implementation**
|
||||
|
||||
To utilize the `onSuccess` handler, simply click on "Event Handlers" in the lower section of the Data Query Editor in the "General" Tab. Then you choose "on Success" and next your desired action.
|
||||
|
||||
<figure><img src="../../.gitbook/assets/Screenshot 2024-03-12 at 18.59.28.png" alt="Data Query Editor Event Handler"><figcaption></figcaption></figure>
|
||||
|
||||
#### onError Handler
|
||||
|
||||
The `onError` handler serves as the counterpart to the `onSuccess` handler, designed to manage scenarios where a data query fails. This could be due to various reasons, such as network issues, API errors, or data inconsistencies.
|
||||
|
||||
<figure><img src="../../.gitbook/assets/Screenshot 2024-03-12 at 19.01.02.png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
To build an event handling for a data query error case, simply choose "Failure" on the Event Selection for the Event Handler. You can specify additionally for the individual Event Handler if there is a special case handling. For example, you would only show a notification on a 4xx or 5xx Response Code for a Restful Data Query.
|
||||
|
||||
<figure><img src="../../.gitbook/assets/Screenshot 2024-03-12 at 19.06.09.png" alt=""><figcaption><p>Create a rule when to use the Event Handler</p></figcaption></figure>
|
||||
|
||||
## Notification tab and Advanced tab
|
||||
|
||||
In notification and advanced tabs, you can configure settings regarding notifications, timeout, periodic run, and more. Settings in **Notification** tab and **Advanced** vary based on trigger mode of your query.
|
||||
|
||||
| Tab | Settings | Inputs change or on page load | Manually invoked |
|
||||
| ---------------- | ------------------------------------------- | :---------------------------: | :--------------: |
|
||||
| **Notification** | Display a Success message after running | 🚫 | ✅ |
|
||||
| | Display a Failure message after running | ✅ | ✅ |
|
||||
| **Advanced** | Display a confirmation modal before running | <p>🚫<br></p> | ✅ |
|
||||
| | Set timeout for query running | ✅ | ✅ |
|
||||
| | Perform query periodically | ✅ | 🚫 |
|
||||
@@ -0,0 +1,102 @@
|
||||
# Bind Query Data to Components
|
||||
|
||||
When building apps in Lowcoder, you can use JavaScript (JS) to access and transform data from objects, including components, queries, and global parameters. When writing JavaScript inside SQL editor, component property's input box, table column settings, etc., always remember to enclose all your JS code inside double curly braces, such as \
|
||||
`{{'hello, ' + currentUser.name}}`.
|
||||
|
||||
## Access data
|
||||
|
||||
Objects have globally unique names, such as `input1`, `query1`, and `table1`. You can refer to the properties of the objects in your app by JS code.
|
||||
|
||||
### Access data in an object
|
||||
|
||||
Lowcoder supports you accessing the data in an object using dot notation (`objectName.keyName`). For example,`{{userInfo.selectedRow.userName}}` accesses the `userName` value in the currently selected row of **Table** `userInfo`.
|
||||
|
||||
When writing JS in `{{ }}` to access values in an object, add a `.` after the object name to trigger an autosuggest menu in case you are not sure about objects' built-in properties or methods.
|
||||
|
||||
**Example**
|
||||
|
||||
This GIF shows how the dot notation triggers an autosuggest menu and displays the properties of `table1`.
|
||||
|
||||
### Access data in an array
|
||||
|
||||
You can access the values in an array by index. The index always starts at 0, so you can use `array[0]` to access the first element of the array.
|
||||
|
||||
**Example**
|
||||
|
||||
The **Data** property of **Table** component is an array of objects. This GIF shows how to access the value of `first_name` in the first element of the **data** array in `table1`.
|
||||
|
||||
## Transform data
|
||||
|
||||
You can leverage built-in JS functions and third-party libraries in `{{ }}` to transform data, such as `filter()`, `map()` and `reduce()` operations.
|
||||
|
||||
**Examples**
|
||||
|
||||
Lowercase a string.
|
||||
|
||||
```javascript
|
||||
{{input1.value.toLowerCase()}}
|
||||
```
|
||||
|
||||
Change date format.
|
||||
|
||||
```javascript
|
||||
{{moment(table1.selectedRow.date_column).format('YYYY-MM-DD')}}
|
||||
```
|
||||
|
||||
Return name from query results.
|
||||
|
||||
```javascript
|
||||
{{query1.data.map(i => i.name)}}.
|
||||
```
|
||||
|
||||
## Restrictions
|
||||
|
||||
The JS code in `{{ }}` should be a single-line code, such as `.map()` or `.reduce()` combined with an arrow function or a ternary operator.
|
||||
|
||||
**Examples**
|
||||
|
||||
```javascript
|
||||
{{query1.data.id.length}} // ✅ to reference a value
|
||||
{{query1.data.map(row => row.id)}} // ✅ .map() + arrow function
|
||||
{{ num1 > num2 ? num1 : num2 }} // ✅ ternary
|
||||
```
|
||||
|
||||
The following JS code examples are illegal in `{{ }}`.
|
||||
|
||||
```javascript
|
||||
{{
|
||||
// ❌ you can't write code like this in {{ }}
|
||||
const array = query1.data;
|
||||
const filterArray = array.filter(it => it.value > 10);
|
||||
return filterArray;
|
||||
}}
|
||||
```
|
||||
|
||||
If you wish to orchestrate multiple lines of JavaScript, Lowcoder supports you writing such code in transformers.
|
||||
|
||||
```javascript
|
||||
// codes inside a transformer
|
||||
if (select.value === "1") {
|
||||
return "Option 1";
|
||||
}
|
||||
if (select.value === "2") {
|
||||
return "Option 2";
|
||||
}
|
||||
return "Option 3";
|
||||
```
|
||||
|
||||
## View data
|
||||
|
||||
Data from queries can be complicated and nested in real cases. Viewing data provides you with the detailed structure of data in objects and helps you understand your data better. Before accessing or transforming data, you may need to view the data and its structure first. Lowcoder offers three ways to view data.
|
||||
|
||||
### View query result
|
||||
|
||||
After running a query inside the query editor by clicking the **Run** button\*\*.\*\* Query result is displayed in the format shown below.
|
||||
|
||||
### View data in Data Browser
|
||||
|
||||
Data browser located in the left pane displays all of the data inside your app. You can click on the node to expand and view the data structure.
|
||||
|
||||
### Real-time view
|
||||
|
||||
When setting up properties or writing JS code inside an editor, you can view the evaluated result in real-time in a box below your editor.
|
||||
@@ -0,0 +1,54 @@
|
||||
# Query library
|
||||
|
||||
**Query Library** lets you store, reuse and share data queries for data sourced across your workspace. Create and run queries in query library, and call them from any Lowcoder app.
|
||||
|
||||
## Features
|
||||
|
||||
The main function of the query \*\*\*\* library is to create and manage reusable queries:
|
||||
|
||||
* Writing queries based on data sources, with the ability to define **Inputs** variables.\\
|
||||
* Importing and triggering queries from query library in apps and modules.\\
|
||||
* Referencing different versions of queries.\\
|
||||
|
||||
## Create a new query
|
||||
|
||||
1. Click **+ New** and select a data source.
|
||||
2. Rename the query on demand.
|
||||
3. Write code and click ▶ **Run** to get results. The results will display in the bottom pane of the window.
|
||||
|
||||
### Input parameters
|
||||
|
||||
There are cases where you want to pass dynamic parameters to a query. Lowcoder supports that by introducing input configuration of a query.
|
||||
|
||||
Click **Add** in the **Inputs** tab in the right pane to add input parameters. Reference them using `{{}}` in the query, then you can input test values to test execution of the query.
|
||||
|
||||
{% hint style="warning" %}
|
||||
You can only reference variables instead of writing JavaScript code in `{{}}`.
|
||||
{% endhint %}
|
||||
|
||||
To edit the name and description of the input variables, click `...` and select **Edit** or directly click the title of the variable.
|
||||
|
||||
## Version management
|
||||
|
||||
Queries may be updated on demand. You can make an adjustment to a query to a newer version and at the same time maintain the older version. Such version management is achievable in query library. Click `···` in the top right corner to publish different versions of queries, and you can view and restore history versions.
|
||||
|
||||
### Publish
|
||||
|
||||
When you finish writing a version of the query, you can publish it. Click `···` > **Publish**. Use [semantic versioning](https://semver.org/) (also known as SemVer) to name your version.
|
||||
|
||||
### History version
|
||||
|
||||
To view and restore the history versions, go to `···` > **History version**.
|
||||
|
||||
You can restore your current draft to a history version by selecting the target version from the history version list and clicking **Restore this version**. Click **Exit** to return to edit mode.
|
||||
|
||||
## Import a query
|
||||
|
||||
1. In an app or module, Click **+ New** in the **Query editor** in the bottom pane, then select **Import from Query Library**.
|
||||
2. Select a query from the library from the dropdown list, choose your desired version and pass in corresponding input parameters.
|
||||
|
||||
For other settings, see .
|
||||
|
||||
## Permissions
|
||||
|
||||
Workspace **Admin** and members of **Developers** group have access to the **Query Library** and have read and write permissions to all queries in the library.
|
||||
Reference in New Issue
Block a user