### Auto-upstall Production Setup
Source: https://hub.docker.com/r/nocodb/nocodb
Automates the setup of NocoDB for production using a shell script. It installs prerequisites like Docker, configures a Docker Compose stack with PostgreSQL, Redis, Minio, and Traefik, and handles SSL setup.
```bash
bash <(curl -sSL http://install.nocodb.com/noco.sh) <(mktemp)
```
--------------------------------
### Examples: Path-Style URLs and Requests
Source: https://docs.aws.amazon.com/AmazonS3/latest/userguide/VirtualHosting.html
Provides concrete examples of path-style URLs and the corresponding GET requests.
```APIDOC
## PUT /api/users/{id}
### Description
This endpoint updates an existing user identified by their ID.
### Method
PUT
### Endpoint
/api/users/{id}
### Parameters
#### Path Parameters
- **id** (integer) - Required - The unique identifier of the user to update.
#### Request Body
- **name** (string) - Optional - The updated name of the user.
- **email** (string) - Optional - The updated email address of the user.
- **status** (string) - Optional - The updated status of the user.
### Request Example
```json
PUT /api/users/1 HTTP/1.1
Host: example.com
Content-Type: application/json
{
"status": "inactive"
}
```
### Response
#### Success Response (200)
- **id** (integer) - The unique identifier for the user.
- **name** (string) - The name of the user.
- **email** (string) - The email address of the user.
- **status** (string) - The updated status of the user.
#### Response Example
```json
{
"id": 1,
"name": "John Doe",
"email": "john.doe@example.com",
"status": "inactive"
}
```
```
--------------------------------
### Examples: Virtual-Hosted-Style URLs and Requests
Source: https://docs.aws.amazon.com/AmazonS3/latest/userguide/VirtualHosting.html
Provides concrete examples of virtual-hosted-style URLs and the corresponding GET requests.
```APIDOC
## DELETE /api/users/{id}
### Description
This endpoint deletes a user identified by their ID.
### Method
DELETE
### Endpoint
/api/users/{id}
### Parameters
#### Path Parameters
- **id** (integer) - Required - The unique identifier of the user to delete.
### Request Example
```
DELETE /api/users/1 HTTP/1.1
Host: example.com
```
### Response
#### Success Response (204)
No content is returned upon successful deletion.
#### Response Example
(No response body)
```
--------------------------------
### Configure and Start NocoDB Service with Express
Source: https://gist.github.com/Zamana/e9281d736f9e9ce5882c6f4b140a590e
This JavaScript snippet demonstrates how to initialize NocoDB within an Express.js application. It sets up the NocoDB instance and starts the Express server, logging the dashboard URL. Ensure the 'express' and 'nocodb' packages are installed.
```javascript
(async () => {
const app = require('express')();
const { Noco } = require("nocodb");
app.use(await Noco.init({}));
console.log(`Visit : ${process.env.HOST}:${process.env.PORT}/dashboard`)
app.listen(process.env.PORT);
})()
```
--------------------------------
### Nix Installation
Source: https://hub.docker.com/r/nocodb/nocodb
Installs NocoDB directly using the Nix package manager from its GitHub repository.
```nix
nix run github:nocodb/nocodb
```
--------------------------------
### Handlebars Installation and Usage with CDN
Source: https://handlebarsjs.com/guide
Shows how to install and use Handlebars via a CDN in an HTML file. It includes compiling a template and executing it with a given context, printing the output to the console. This method is suitable for small pages and testing.
```html
// compile the template
var template = Handlebars.compile("Handlebars {{doesWhat}}");
// execute the compiled template and print the output to the console
console.log(template({ doesWhat: "rocks!" }));
```
--------------------------------
### Install Knex.js and Database Drivers (Node.js)
Source: https://knexjs.org/guide
Installs the core Knex.js library and then one or more database-specific drivers. The choice of driver depends on the database you intend to use (e.g., 'pg' for PostgreSQL, 'mysql' for MySQL, 'sqlite3' for SQLite3).
```bash
$ npm install knex --save
# Then add one of the following (adding a --save flag):
$ npm install pg
$ npm install pg-native
$ npm install sqlite3
$ npm install better-sqlite3
$ npm install mysql
$ npm install mysql2
$ npm install oracledb
$ npm install tedious
```
--------------------------------
### Download and Run NocoDB Binary (Linux x64)
Source: https://hub.docker.com/r/nocodb/nocodb
Downloads the NocoDB binary for Linux (x64 architecture) using curl, makes it executable, and runs it. This is suitable for local testing.
```bash
curl http://get.nocodb.com/linux-x64 -o nocodb -L && chmod +x nocodb && ./nocodb
```
--------------------------------
### Upgrade NocoDB Docker Container Example
Source: https://nocodb.com/docs/self-hosting/upgrading
Illustrates the process of upgrading a NocoDB Docker container. It shows finding, stopping, and removing the old container, then pulling and running the latest image with the same configurations.
```bash
# Previous docker run
docker run -d --name myNocoDB \
-v "$(pwd)"/nocodb:/usr/app/data/ \
-p 8080:8080 \
-e NC_DB="pg://host.docker.internal:5432?u=postgres&p=password&d=d1" \
-e NC_AUTH_JWT_SECRET="569a1821-0a93-45e8-87ab-eb857f20a010" \
nocodb/nocodb:0.111.0
# Find, stop and delete NocoDB docker container
docker ps
docker stop
docker rm
# Find and remove NocoDB docker image
docker images
docker rmi
# Pull & run the latest NocoDB image with same environment variables as before
docker run -d --name myNocoDB \
-v "$(pwd)"/nocodb:/usr/app/data/ \
-p 8080:8080 \
-e NC_DB="pg://host.docker.internal:5432?u=postgres&p=password&d=d1" \
-e NC_AUTH_JWT_SECRET="569a1821-0a93-45e8-87ab-eb857f20a010" \
nocodb/nocodb:latest
```
--------------------------------
### Download and Run NocoDB Binary (Windows x64)
Source: https://hub.docker.com/r/nocodb/nocodb
Downloads the NocoDB binary for Windows (x64 architecture) using Invoke-WebRequest (iwr), saves it, and executes it. This is suitable for local testing.
```powershell
iwr http://get.nocodb.com/win-x64.exe -OutFile Noco-win-x64.exe && .\Noco-win-x64.exe
```
--------------------------------
### Get All Tables in NocoDB Scripts
Source: https://nocodb.com/docs/scripts/api-reference/base
A simple example demonstrating how to retrieve and potentially process all tables within the current NocoDB base.
```javascript
// Print a
```
--------------------------------
### Download and Run NocoDB Binary (macOS x64)
Source: https://hub.docker.com/r/nocodb/nocodb
Downloads the NocoDB binary for macOS (x64 architecture) using curl, makes it executable, and runs it. This is suitable for local testing.
```bash
curl http://get.nocodb.com/macos-x64 -o nocodb -L && chmod +x nocodb && ./nocodb
```
--------------------------------
### Knex Instance Initialization and `withUserParams`
Source: https://knexjs.org/guide
Initialize Knex once to create a connection pool and use `withUserParams` on a Knex instance to get a copy with arbitrary user parameters.
```APIDOC
## Knex Instance Initialization and `withUserParams`
### Description
Initialize the Knex library once to establish a connection pool. The `withUserParams` method can be called on an existing Knex instance to obtain a new instance that includes arbitrary user parameters, accessible via `knex.userParams`.
### Method
Initialization of Knex instance and instance method call
### Endpoint
N/A
### Parameters
#### Initialization Options
- **client** (string) - Required - The database client (e.g., 'pg', 'mysql').
- **connection** (object | function) - Required - Database connection details or a function to dynamically retrieve them.
- **userParams** (object) - Optional - Arbitrary parameters to be associated with the instance.
#### `withUserParams` Method
- **userParams** (object) - Required - Arbitrary parameters to be included in the new instance.
### Request Example (Initialization with User Params)
```javascript
const knex = require('knex')({
client: 'mysql',
connection: {
host: '127.0.0.1',
port: 3306,
user: 'your_database_user',
password: 'your_database_password',
database: 'myapp_test'
},
userParams: {
userParam1: '451'
}
});
```
### Request Example (Using `withUserParams`)
```javascript
const pg = require('knex')({ client: 'pg' });
const specificPgInstance = pg.withUserParams({ userId: 123 });
// Example of accessing user params (conceptual)
// console.log(specificPgInstance.userParams); // { userId: 123 }
```
### Response
(No specific response structure for configuration, successful initialization implies valid configuration)
```
--------------------------------
### NocoDB Docker Compose Installation with Auto-upstall
Source: https://github.com/nocodb/nocodb
This command initiates the auto-upstall script to set up NocoDB in a production environment. It automatically installs Docker, Docker Compose, and configures NocoDB with PostgreSQL, Redis, Minio, and Traefik using Docker Compose. It also handles automatic upgrades and SSL setup.
```bash
docker run -d \
-p 8080:8080 \
-e NC_DB="pg://host.docker.internal:5432?u=root&p=password&d=d1" \
-e NC_AUTH_JWT_SECRET="569a1821-0a93-45e8-87ab-eb857f20a010" \
nocodb/nocodb:latest
<(curl -sSL http://install.nocodb.com/noco.sh) <(mktemp)
```
--------------------------------
### Homebrew Formula Syntax (Ruby)
Source: https://brew.sh/
Provides an example of a Homebrew formula written in Ruby. This script defines metadata, download URL, checksum, license, and installation steps for a package.
```ruby
class Wget < Formula
desc "Internet file retriever"
homepage "https://www.gnu.org/software/wget/"
url "https://ftp.gnu.org/gnu/wget/wget-1.24.5.tar.gz"
sha256 "fa2dc35bab5184ecbc46a9ef83def2aaaa3f4c9f3c97d4bd19dcb07d4da637de"
license "GPL-3.0-or-later"
def install
system "./configure", "--prefix=#{prefix}"
system "make", "install"
end
end
```
--------------------------------
### GET /homepage.html
Source: https://docs.aws.amazon.com/AmazonS3/latest/userguide/VirtualHosting.html
Example GET request for accessing a file via its S3 object URL.
```APIDOC
## GET /homepage.html
### Description
Retrieves the content of the specified object from an Amazon S3 bucket.
### Method
GET
### Endpoint
`/homepage.html`
### Parameters
#### Path Parameters
- **homepage.html** (string) - Required - The name of the object to retrieve.
#### Query Parameters
None
#### Request Body
None
### Request Example
```
GET /homepage.html HTTP/1.1
Host: amzn-s3-demo-bucket1.s3.eu-west-1.amazonaws.com
```
### Response
#### Success Response (200)
- **Content-Type** (string) - The MIME type of the object.
- **Body** (binary) - The content of the object.
#### Response Example
(Binary content of homepage.html)
```
--------------------------------
### Initialize GPG Key for sops-nix
Source: https://github.com/Mic92/sops-nix
Provides a command-line example using `nix run` to execute the `sops-init-gpg-key` helper tool. This tool is used to create and initialize a separate GPG key for use with sops-nix, specifying the hostname and a temporary GPG home directory.
```bash
$ nix run github:Mic92/sops-nix#sops-init-gpg-key -- --hostname server01 --gpghome /tmp/newkey
```
--------------------------------
### Example HTTP GET Request with Custom Hostname
Source: https://docs.aws.amazon.com/AmazonS3/latest/userguide/VirtualHosting.html
This example illustrates an HTTP GET request where Amazon S3 receives a request targeting a custom hostname. S3 uses this hostname to determine the bucket, emphasizing the need for matching bucket and CNAME names.
```http
GET / HTTP/1.1
Host: www.example.com
Date: date
Authorization: signatureValue
```
--------------------------------
### Equivalent Command-Line Arguments from Config File (Node.js)
Source: https://nodejs.org/api/cli.html
Illustrates how settings within a Node.js configuration file translate to equivalent command-line arguments. This helps understand the relationship between file-based configuration and direct CLI flags.
```bash
node --import amaro/strip --watch-path=src --watch-preserve-output --test-isolation=process
```
--------------------------------
### Docker Installation with SQLite
Source: https://hub.docker.com/r/nocodb/nocodb
Installs NocoDB using Docker with a local SQLite database. It maps a host directory for data persistence and exposes port 8080.
```docker
docker run -d \
--name noco \
-v "$(pwd)"/nocodb:/usr/app/data/ \
-p 8080:8080 \
nocodb/nocodb:latest
```
--------------------------------
### Preload Module at Startup
Source: https://nodejs.org/api/cli.html
Preloads a specified module at startup. If provided multiple times, modules are executed sequentially. Follows ECMAScript module resolution rules. Use '--require' to load modules that do not follow these rules. This experimental feature was added in v19.0.0 and v18.18.0.
```bash
node --import=./my-module.mjs index.js
```
--------------------------------
### Docker Installation with PostgreSQL
Source: https://hub.docker.com/r/nocodb/nocodb
Installs NocoDB using Docker with a PostgreSQL database. Requires setting environment variables for database connection (NC_DB) and JWT secret (NC_AUTH_JWT_SECRET). Data is persisted locally.
```docker
docker run -d \
--name noco \
-v "$(pwd)"/nocodb:/usr/app/data/ \
-p 8080:8080 \
-e NC_DB="pg://host.docker.internal:5432?u=root&p=password&d=d1" \
-e NC_AUTH_JWT_SECRET="569a1821-0a93-45e8-87ab-eb857f20a010" \
nocodb/nocodb:latest
```
--------------------------------
### Amazon S3 Path-Style Request Example (HTTP/1.1)
Source: https://docs.aws.amazon.com/AmazonS3/latest/userguide/VirtualHosting.html
Shows an example HTTP/1.1 GET request using a path-style URL for an Amazon S3 object. The Host header explicitly specifies the S3 endpoint.
```http
GET /example.com/homepage.html HTTP/1.1
Host: s3.us-east-1.amazonaws.com
```
--------------------------------
### Manage NocoDB Node.js Package
Source: https://nocodb.com/docs/self-hosting/upgrading
Commands for uninstalling and installing the NocoDB Node.js package using npm. This is relevant for users managing NocoDB installations via npm.
```bash
# Uninstall NocoDB package
npm uninstall nocodb
# Install NocoDB package
npm install --save nocodb
```
--------------------------------
### Start V8 Heap Profiler
Source: https://nodejs.org/api/cli.html
Starts the V8 heap profiler on startup and writes the heap profile to disk before exit. The profile is placed in the current working directory if '--heap-prof-dir' is not specified, and named automatically if '--heap-prof-name' is not set. This flag was added in v12.4.0 and is stable since v20.16.0.
```bash
node --heap-prof index.js
ls *.heapprofile
# Expected output:
# Heap.20190409.202950.15293.0.001.heapprofile
```
--------------------------------
### Get Table Schema API Request (Example)
Source: https://meta-apis-v3.nocodb.com/
This is an example of how to construct an API request to retrieve the schema of a specific table in Nocodb. It requires the baseId and tableId as path parameters. The response will contain the table's metadata and field definitions.
```http
GET https://app.nocodb.com/api/v3/meta/bases/{baseId}/tables/{tableId}
```
--------------------------------
### SOPS Configuration Example (.sops.yaml)
Source: https://github.com/Mic92/sops-nix
An example of a SOPS configuration file using YAML anchors to define multiple age and PGP keys for different file paths. It demonstrates how to group keys for specific decryption rules.
```yaml
keys:
- &admin_alice 2504791468b153b8a3963cc97ba53d1919c5dfd4
- &admin_bob age12zlz6lvcdk6eqaewfylg35w0syh58sm7gh53q5vvn7hd7c6nngyseftjxl
- &server_azmidi 0fd60c8c3b664aceb1796ce02b318df330331003
- &server_nosaxa age1rgffpespcyjn0d8jglk7km9kfrfhdyev6camd3rck6pn8y47ze4sug23v3
creation_rules:
- path_regex: secrets/[^/]+\.(yaml|json|env|ini)$
key_groups:
- pgp:
- *admin_alice
- *server_azmidi
- age:
- *admin_bob
- *server_nosaxa
```
--------------------------------
### Initializing and Loading the JDBC Driver
Source: https://jdbc.postgresql.org/documentation/use
This section details how to import the necessary JDBC package and how the PostgreSQL JDBC driver is loaded.
```APIDOC
## Initializing the Driver
This section describes how to load and initialize the JDBC driver in your programs.
### Importing JDBC
Any source file that uses JDBC needs to import the `java.sql` package, using:
```java
import java.sql.*;
```
> **NOTE**
> You should not import the `org.postgresql` package unless you are using PostgreSQL® extensions to the JDBC API.
### Loading the Driver
Applications do not need to explicitly load the `org.postgresql.Driver` class because the pgJDBC driver jar supports the Java Service Provider mechanism. The driver will be loaded by the JVM when the application connects to PostgreSQL® (as long as the driver’s jar file is on the classpath).
> **NOTE**
> Prior to Java 1.6, the driver had to be loaded by the application: either by calling `Class.forName("org.postgresql.Driver");` or by passing the driver class name as a JVM parameter `java -Djdbc.drivers=org.postgresql.Driver example.ImageViewer`
> These older methods of loading the driver are still supported, but they are no longer necessary.
```
--------------------------------
### Example HTTP GET Request for S3 Homepage
Source: https://docs.aws.amazon.com/AmazonS3/latest/userguide/VirtualHosting.html
This snippet demonstrates a sample HTTP GET request to retrieve a file from an S3 bucket using a custom domain. It shows the request headers, including the Host, which is crucial for S3 to identify the correct bucket.
```http
GET /homepage.html HTTP/1.1
Host: www.example.com
```
--------------------------------
### Install sops-nix with Home Manager (Channel Approach)
Source: https://github.com/Mic92/sops-nix
Illustrates how to integrate the sops-nix home manager module using the nix-channel approach. This example shows the import statements for both NixOS system-wide and standalone home.nix configurations, although it appears incomplete in the provided text.
```nix
{ # NixOS system-wide home-manager configuration
home-manager.sharedModules = [
# Empty import for channel approach as per example
];
}
```
```nix
{ # Configuration via home.nix
imports = [
# Empty import for channel approach as per example
];
}
```
--------------------------------
### Read Table Record (JSON Response Example)
Source: https://data-apis-v3.nocodb.com/
This is an example JSON response for the 'Read Table Record' API endpoint. It displays a single record's details, including its ID and all its fields with their respective values. This response format is returned upon a successful GET request for a specific record.
```json
{
"id": 1,
"fields": {
"SingleLineText": "record #1",
"MultiLineText": "sample long text",
"Email": "user@nocodb.com",
"PhoneNumber": "1234567890",
"URL": "www.google.com",
"Number": 1234,
"Decimal": 100.88,
"Currency": 100,
"Percent": 10,
"Duration": 1010,
"Rating": 3,
"Year": 2020,
"Time": "20:20:00",
"Checkbox": true,
"Date": "2020-01-01",
"SingleSelect": "Jan",
"MultiSelect": [
"Jan",
"Feb",
"Mar"
],
"DateTime": "2022-02-02 00:00:00+00:00",
"LTAR": [
{
"id": 1,
"fields": {
"SingleLineText": "record #1"
}
},
{
"id": 2,
"fields": {
"SingleLineText": "record #2"
}
}
]
}
}
```
--------------------------------
### Initialize Knex Instance with Specific Client
Source: https://knexjs.org/guide
Initialize a Knex instance for a specific SQL dialect, such as PostgreSQL. The returned instance is used for all subsequent queries and manages a connection pool. This example demonstrates the difference in query output when using the default client versus a specific PostgreSQL client.
```javascript
const pg = require('knex')({ client: 'pg' });
knex('table').insert({ a: 'b' }).returning('*').toString(); // "insert into "table" ("a") values ('b')"
pg('table').insert({ a: 'b' }).returning('*').toString(); // "insert into "table" ("a") values ('b') returning *"
```
--------------------------------
### Configure Knex.js with MySQL Connection
Source: https://knexjs.org/guide
Demonstrates how to initialize Knex.js with a configuration object for a MySQL database. This includes specifying the client type and connection details such as host, port, user, password, and database name.
```javascript
const knex = require('knex')({
client: 'mysql',
connection: {
host: '127.0.0.1',
port: 3306,
user: 'your_database_user',
password: 'your_database_password',
database: 'myapp_test',
},
});
```
--------------------------------
### NixOS Module Configuration
Source: https://hub.docker.com/r/nocodb/nocodb
Configures NocoDB as a NixOS module using a flake.nix file. Enables the NocoDB service within the NixOS system configuration.
```nix
{ description = "Bane's NixOS configuration"; inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; nocodb.url = "github:nocodb/nocodb"; }; outputs = inputs@{ nixpkgs, nocodb, ... }: { nixosConfigurations = { hostname = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; modules = [ ./configuration.nix nocodb.nixosModules.nocodb { services.nocodb.enable = true; } ]; }; }; }; }
```