### nb db start examples Source: https://docs.nocobase.com/api/cli/db/start Examples of starting the built-in database container: with default env, with --env app1, and with --env app1 --verbose to show underlying Docker command output. ```bash nb db start ``` ```bash nb db start --env app1 ``` ```bash nb db start --env app1 --verbose ``` -------------------------------- ### nb skills install examples Source: https://docs.nocobase.com/api/cli/skills/install Shows common usage examples: basic install, skip confirmation with --yes, verbose output, and JSON output. ```bash nb skills install nb skills install --yes nb skills install --verbose nb skills install --json ``` -------------------------------- ### nb app start examples Source: https://docs.nocobase.com/api/cli/app/start Common invocations: start with current env, specify env, enable verbose output, and use Docker env. ```bash nb app start ``` ```bash nb app start --env local ``` ```bash nb app start --env local --verbose ``` ```bash nb app start --env local-docker ``` -------------------------------- ### Manual Installation Commands Source: https://docs.nocobase.com/ai-builder Installs the NocoBase CLI globally and initializes the project. After running, your browser opens a visual configuration page for installing NocoBase Skills, configuring the database, and starting the application. ```bash npm install -g @nocobase/cli@alpha nb init --ui ``` -------------------------------- ### CLI mode: Initialize NocoBase with 'nb init --ui' Source: https://docs.nocobase.com/ai-builder/env-bootstrap Run this CLI command to start the interactive installation of NocoBase. The quickest way is using Docker mode; ensure Node, Docker, and Yarn are installed before proceeding. ```bash nb init --ui ``` -------------------------------- ### nb app autostart examples Source: https://docs.nocobase.com/api/cli/app/autostart Examples of enabling autostart, listing status, and starting enabled envs. The --verbose flag shows underlying startup output. ```bash # Enable autostart for the current env nb app autostart enable ``` ```bash # Enable autostart for a specific env nb app autostart enable --env app1 --yes ``` ```bash # Show autostart status nb app autostart list ``` ```bash # Start every enabled env nb app autostart run ``` ```bash # Show underlying startup output nb app autostart run --verbose ``` -------------------------------- ### Prompt mode: Start current instance Source: https://docs.nocobase.com/ai-builder/env-bootstrap Use this prompt to start the current NocoBase instance. ```text Help me start the current instance ``` -------------------------------- ### Prompt mode: Install NocoBase Source: https://docs.nocobase.com/ai-builder/env-bootstrap Use this prompt to install a new NocoBase instance. The quickest way is using Docker mode; ensure Node, Docker, and Yarn are installed before proceeding. ```text Help me install NocoBase ``` -------------------------------- ### CLI mode: Start instance with 'nb app start' Source: https://docs.nocobase.com/ai-builder/env-bootstrap Run this CLI command to start the current NocoBase instance. ```bash nb app start ``` -------------------------------- ### Continue after prepare-only with license activate and app start Source: https://docs.nocobase.com/api/cli/init Shows how to continue a prepared env flow after using --prepare-only. The app start command completes the first installation and switches the env from prepared to normal installed state. ```bash nb license activate --env app1 ``` ```bash nb app start --env app1 ``` -------------------------------- ### nb config examples Source: https://docs.nocobase.com/api/cli/config A series of example commands for listing, getting, setting, and deleting configuration keys. ```bash nb config list nb config get update.policy nb config set update.policy auto nb config get proxy.nb-cli-root nb config set proxy.nb-cli-root /workspace nb config set proxy.upstream-host host.docker.internal nb config set proxy.nginx-driver docker nb config set proxy.caddy-driver local nb config get docker.network nb config set docker.network nocobase nb config get nb-image-registry nb config set nb-image-registry aliyun nb config set nb-image-variant full-no-nginx nb config set bin.nginx /usr/sbin/nginx nb config set bin.git /usr/bin/git nb config set bin.pnpm /usr/local/bin/pnpm nb config delete docker.container-prefix ``` -------------------------------- ### Prepare first, then activate license and start later Source: https://docs.nocobase.com/api/cli/init Prepares the environment without installing, then activates the license and starts the app later. Use --prepare-only to only save env config and copy hook files. ```bash nb init --env app1 --prepare-only ``` ```bash nb license activate --env app1 ``` ```bash nb app start --env app1 ``` -------------------------------- ### Build and start NocoBase in production environment Source: https://docs.nocobase.com/get-started/installation/git Builds the project and starts the production server. Not recommended for production deployment from source; refer to Production Deployment instead. ```bash yarn build yarn start ``` -------------------------------- ### nb proxy caddy use examples Source: https://docs.nocobase.com/api/cli/proxy/caddy/use Provides examples of switching the driver to `local` and `docker`. The command saves the result to `proxy.caddy-driver`, and later commands like `start`, `reload`, `stop`, `status`, and `info` use the current driver. ```bash nb proxy caddy use local nb proxy caddy use docker ``` -------------------------------- ### Local development commands Source: https://docs.nocobase.com/get-started/translations Commands to install dependencies and start the development server for the docs site. Run from the docs directory after cloning the repository. ```bash cd docs yarn install yarn dev ``` -------------------------------- ### getVarInfos Usage Examples Source: https://docs.nocobase.com/runjs/context/get-var Three usage examples: get variable structure under 'record' with maxDepth 3, get structure of 'popup.record', and get complete top-level structure with default maxDepth. Each returns a Promise of variable path to structural info. ```javascript // Get the variable structure under record (expanded up to 3 levels) const vars = await ctx.getVarInfos({ path: 'record', maxDepth: 3 }); ``` ```javascript // Get the structure of popup.record const vars = await ctx.getVarInfos({ path: 'popup.record', maxDepth: 3 }); ``` ```javascript // Get the complete top-level variable structure (default maxDepth=3) const vars = await ctx.getVarInfos(); ``` -------------------------------- ### Start NocoBase in development mode Source: https://docs.nocobase.com/get-started/installation/create-nocobase-app Start the NocoBase application in development environment. ```bash yarn dev ``` -------------------------------- ### Examples: nb api resource get Source: https://docs.nocobase.com/api/cli/api/resource/get Two example commands: one retrieves a user with primary key 1, the other retrieves a comment with primary key 2 from a post with source ID 1. ```bash nb api resource get --resource users --filter-by-tk 1 nb api resource get --resource posts.comments --source-id 1 --filter-by-tk 2 ``` -------------------------------- ### Expected output of wsl --list --verbose Source: https://docs.nocobase.com/ai/windows-wsl Example output showing an Ubuntu distribution running with WSL version 2. Use this to verify that the installed distribution is using WSL 2. ```text NAME STATE VERSION * Ubuntu Running 2 ``` -------------------------------- ### Initial commands after local installation Source: https://docs.nocobase.com/nocobase-cli/installation/cli Run these commands after installing a local application to select the environment, start the app, view logs, and list plugins. ```bash nb env use app1 nb app start nb app logs nb plugin list ``` -------------------------------- ### Quick install with basic authentication and custom admin Source: https://docs.nocobase.com/api/cli/init Installs non-interactively with basic authentication and custom admin credentials using --root-username and --root-password. ```bash nb init --env app1 --yes \ --auth-type basic \ --root-username admin \ --root-password secret123 ``` -------------------------------- ### Start Codex CLI Source: https://docs.nocobase.com/ai/windows-wsl Launches the Codex CLI. The first run prompts you to sign in; authenticate with a ChatGPT account or OpenAI API key. ```bash codex ``` -------------------------------- ### Examples: nb config get for various keys Source: https://docs.nocobase.com/api/cli/config/get Example invocations of `nb config get` for common configuration keys such as `locale`, `update.policy`, `license.pkg-url`, `docker.network`, `docker.container-prefix`, `nb-image-registry`, `nb-image-variant`, `proxy.nb-cli-root`, `proxy.upstream-host`, `proxy.nginx-driver`, `proxy.caddy-driver`, `bin.nginx`, and `bin.git`. Each returns the effective value or the default if not set. ```bash nb config get locale ``` ```bash nb config get update.policy ``` ```bash nb config get license.pkg-url ``` ```bash nb config get docker.network ``` ```bash nb config get docker.container-prefix ``` ```bash nb config get nb-image-registry ``` ```bash nb config get nb-image-variant ``` ```bash nb config get proxy.nb-cli-root ``` ```bash nb config get proxy.upstream-host ``` ```bash nb config get proxy.nginx-driver ``` ```bash nb config get proxy.caddy-driver ``` ```bash nb config get bin.nginx ``` ```bash nb config get bin.git ``` -------------------------------- ### Open the local browser wizard with nb init --ui Source: https://docs.nocobase.com/api/cli/init Launches the setup wizard in a local browser. Use --ui-port to specify a custom port (default is 3000). ```bash nb init --ui ``` ```bash nb init --ui --ui-port 3000 ``` -------------------------------- ### Create NocoBase project with PostgreSQL (beta version) Source: https://docs.nocobase.com/get-started/deployment/intranet/create-nocobase-app Run on a machine with npm access. Switch to the target parent directory (e.g., cd /app) so the project path matches the intranet deployment path. Uses production mode and skips dev dependencies. ```bash npx create-nocobase-app@beta my-nocobase-app -d postgres \ --skip-dev-dependencies \ -e APP_ENV=production \ -e DB_HOST=localhost \ -e DB_PORT=5432 \ -e DB_DATABASE=nocobase \ -e DB_USER=nocobase \ -e DB_PASSWORD=nocobase \ -e TZ=Asia/Shanghai ``` -------------------------------- ### Example stable URL Source: https://docs.nocobase.com/file-manager/stable-url An example of a stable URL for a file record. When APP_PUBLIC_PATH=/nocobase is configured, the URL starts with /nocobase/files/. ```text /files/main/main/attachments/42.pdf ``` -------------------------------- ### Examples: nb source download Source: https://docs.nocobase.com/api/cli/source/download Various command examples demonstrating different source types, flags, and options. ```bash nb source download ``` ```bash nb source download -y --source npm --version alpha ``` ```bash nb source download -y --source npm --version alpha --no-build ``` ```bash nb source download --source npm --version alpha --output-dir=./app ``` ```bash nb source download --source docker --version alpha --docker-registry=nocobase/nocobase --docker-platform=linux/arm64 ``` ```bash nb source download -y --source docker --version alpha --docker-save -o ./docker-images ``` ```bash nb source download --source git --version alpha --git-url=git@github.com:nocobase/nocobase.git ``` ```bash nb source download --source git --version fix/cli-v2 ``` ```bash nb source download -y --source npm --version alpha --build-dts ``` ```bash nb source download -y --source npm --version alpha --npm-registry=https://registry.npmmirror.com ``` ```bash nb source download -y --source git --version beta --hook-script ./hooks.mjs ``` -------------------------------- ### LibreOffice installation script (install-libreoffice.sh) Source: https://docs.nocobase.com/template-print Bash script that downloads and installs LibreOffice 24.8.5.2 on a Debian-based system. It checks for existing installations, installs dependencies, downloads the tarball, extracts it, installs the .deb packages, and creates a symlink to /usr/bin/libreoffice. The script exits with an error if any step fails. ```bash #!/bin/bash # Define variables INSTALL_DIR="/opt/libreoffice24.8" DOWNLOAD_URL="https://downloadarchive.documentfoundation.org/libreoffice/old/24.8.5.2/deb/x86_64/LibreOffice_24.8.5.2_Linux_x86-64_deb.tar.gz" # Check if LibreOffice is already installed if [ -d "$INSTALL_DIR" ]; then echo "LibreOffice is already installed, skipping installation." exit 0 fi # Update APT and install dependencies apt-get update apt-get install -y \ libfreetype6 \ fontconfig \ libgssapi-krb5-2 \ libxml2 \ libnss3 \ libdbus-1-3 \ libcairo2 \ libxslt1.1 \ libglib2.0-0 \ libcups2 \ libx11-xcb1 \ fonts-liberation \ fonts-noto-cjk \ wget rm -rf /var/lib/apt/lists/* cd /app/nocobase/storage/scripts # Download and install LibreOffice if not already present if [ ! -d "./libreoffice" ]; then rm -rf libreoffice.tar.gz wget --no-check-certificate -O libreoffice.tar.gz $DOWNLOAD_URL if [ $? -ne 0 ]; then echo "Failed to download LibreOffice." exit 1 fi rm -rf libreoffice && mkdir libreoffice tar -zxvf libreoffice.tar.gz -C ./libreoffice --strip-components=1 if [ $? -ne 0 ]; then echo "Failed to extract LibreOffice." exit 1 fi fi # Install LibreOffice dpkg -i libreoffice/DEBS/*.deb ln -s /opt/libreoffice24.8/program/soffice.bin /usr/bin/libreoffice libreoffice --version if [ $? -ne 0 ]; then echo "Failed to install LibreOffice." exit 1 fi echo "LibreOffice installation completed successfully." ``` -------------------------------- ### Verify LibreOffice installation Source: https://docs.nocobase.com/template-print Runs the libreoffice --version command inside the app container to confirm the installation. The expected output shows LibreOffice 24.8.4.2. ```bash $ docker compose exec app bash -c "libreoffice --version" LibreOffice 24.8.4.2 bb3cfa12c7b1bf994ecc5649a80400d06cd71002 ``` -------------------------------- ### yarn nocobase migration run example Source: https://docs.nocobase.com/ops-management/migration-manager Example command to run a migration file with variables and secrets. ```bash yarn nocobase migration run /your/path/migration_1775658568158.nbdata \ --var A=a --var B=b \ --secret C=c --secret D=d ``` -------------------------------- ### List available WSL distributions Source: https://docs.nocobase.com/ai/windows-wsl Lists all available Linux distributions that can be installed via WSL. ```powershell wsl --list --online ``` -------------------------------- ### Quick Start: Use, Generate, and Reload Caddy Proxy Source: https://docs.nocobase.com/nocobase-cli/production/reverse-proxy/caddy Run these three commands in order to set up the Caddy entry layer with Docker. Replace the host with your domain and adjust the environment as needed. If Caddy is installed locally, change the first command to 'nb proxy caddy use local'. ```bash nb proxy caddy use docker nb proxy caddy generate --env test2 --host c.local.nocobase.com nb proxy caddy reload ``` -------------------------------- ### getField() example Source: https://docs.nocobase.com/api/database/collection Gets the field object with the corresponding name defined in the collection. The example creates a 'posts' collection with a 'title' string field and retrieves it. ```javascript const posts = db.collection({ name: 'posts', fields: [ { type: 'string', name: 'title', }, ], }); const field = posts.getField('title'); ``` -------------------------------- ### Create NocoBase project with PostgreSQL (latest version) Source: https://docs.nocobase.com/get-started/deployment/intranet/create-nocobase-app Run on a machine with npm access. Switch to the target parent directory (e.g., cd /app) so the project path matches the intranet deployment path. Uses production mode and skips dev dependencies. ```bash yarn create nocobase-app my-nocobase-app -d postgres \ --skip-dev-dependencies \ -e APP_ENV=production \ -e DB_HOST=localhost \ -e DB_PORT=5432 \ -e DB_DATABASE=nocobase \ -e DB_USER=nocobase \ -e DB_PASSWORD=nocobase \ -e TZ=Asia/Shanghai ``` -------------------------------- ### Install Yarn 1.x with npm Source: https://docs.nocobase.com/ai/windows-wsl If Corepack is not available, install Yarn 1.x globally with npm. ```bash npm install -g yarn@1.22.22 yarn -v ``` -------------------------------- ### nb api resource examples Source: https://docs.nocobase.com/api/cli/api/resource Example invocations for listing, getting, creating, and querying resources, including association resources with --source-id. ```bash nb api resource list --resource users ``` ```bash nb api resource get --resource users --filter-by-tk 1 ``` ```bash nb api resource create --resource users --values '{"nickname":"Ada"}' ``` ```bash nb api resource list --resource posts.comments --source-id 1 --fields id --fields content ``` -------------------------------- ### Examples: nb portal config Source: https://docs.nocobase.com/api/cli/portal/config Four example invocations showing how to set the portal path, source storage, and Git repository details. ```bash nb portal config customer --path ./portals/customer ``` ```bash nb portal config customer --source-storage nocobase ``` ```bash nb portal config customer --source-storage git --git-repo git@github.com:nocobase/customer-portal.git ``` ```bash nb portal config customer --git-branch main --git-path portals/customer ``` -------------------------------- ### Install NocoBase Source: https://docs.nocobase.com/get-started/deployment/intranet/create-nocobase-app Run the NocoBase installation command. This step is part of the commercial plugin workflow; skip if using open-source only. ```bash yarn nocobase install ``` -------------------------------- ### startOfD example Source: https://docs.nocobase.com/template-print/syntax/formatters/date-formatting Sets the date to the start of the specified time unit. The unit is required; patternIn is optional. The output is the date set to the start of the unit. ```plaintext '2017-05-10T15:57:23.769561+03:00':startOfD('day') // Outputs "2017-05-10T00:00:00.000Z" '2017-05-10 15:57:23.769561+03:00':startOfD('month') // Outputs "2017-05-01T00:00:00.000Z" '20160131':startOfD('day') // Outputs "2016-01-31T00:00:00.000Z" '20160131':startOfD('month') // Outputs "2016-01-01T00:00:00.000Z" '31-2016-01':startOfD('month', 'DD-YYYY-MM') // Outputs "2016-01-01T00:00:00.000Z" ``` -------------------------------- ### Generate and start Caddy for one env Source: https://docs.nocobase.com/api/cli/proxy Example commands to generate and start Caddy for a single env using the local driver. ```bash # Generate and start Caddy for one env nb proxy caddy use local nb proxy caddy generate --env demo --host demo.local.nocobase.com nb proxy caddy start ``` -------------------------------- ### Create NocoBase project with MySQL (beta version) Source: https://docs.nocobase.com/get-started/deployment/intranet/create-nocobase-app Run on a machine with npm access. Switch to the target parent directory (e.g., cd /app) so the project path matches the intranet deployment path. Uses production mode and skips dev dependencies. ```bash npx create-nocobase-app@beta my-nocobase-app -d mysql \ --skip-dev-dependencies \ -e APP_ENV=production \ -e DB_HOST=localhost \ -e DB_PORT=3306 \ -e DB_DATABASE=nocobase \ -e DB_USER=nocobase \ -e DB_PASSWORD=nocobase \ -e TZ=Asia/Shanghai ``` -------------------------------- ### Generate and start Nginx for one env Source: https://docs.nocobase.com/api/cli/proxy Example commands to generate and start Nginx for a single env using the docker driver. ```bash # Generate and start Nginx for one env nb proxy nginx use docker nb proxy nginx generate --env demo --host demo.local.nocobase.com nb proxy nginx start ``` -------------------------------- ### Change directory to project Source: https://docs.nocobase.com/get-started/deployment/intranet/create-nocobase-app Navigate into the created project directory before installing dependencies. ```bash cd my-nocobase-app ``` -------------------------------- ### Select Caddy Runtime: Local Installation Source: https://docs.nocobase.com/nocobase-cli/production/reverse-proxy/caddy Use this command if Caddy is already installed on the current machine. This is an alternative to the Docker method. ```bash nb proxy caddy use local ``` -------------------------------- ### Enable the example plugin with yarn pm Source: https://docs.nocobase.com/plugin-development/client/examples/fullstack-plugin Run this command to enable the full example plugin locally. It is the only code block on the page; the rest of the content is prose describing the plugin's capabilities and prerequisites. ```bash yarn pm enable @nocobase-example/plugin-custom-table-block-resource ``` -------------------------------- ### :count(start) usage example Source: https://docs.nocobase.com/template-print/syntax/formatters/array-formatting Counts the row number in an array and outputs the current row number, regardless of the value of `id`. Starting from v4.0.0, this formatter has been replaced internally by `:cumCount`. The `start` parameter is optional and sets the starting value for the count. ```plaintext {d[i].id:count()} ``` -------------------------------- ### Create NocoBase project with MariaDB (beta version) Source: https://docs.nocobase.com/get-started/deployment/intranet/create-nocobase-app Run on a machine with npm access. Switch to the target parent directory (e.g., cd /app) so the project path matches the intranet deployment path. Uses production mode and skips dev dependencies. ```bash npx create-nocobase-app@beta my-nocobase-app -d mariadb \ --skip-dev-dependencies \ -e APP_ENV=production \ -e DB_HOST=localhost \ -e DB_PORT=3306 \ -e DB_DATABASE=nocobase \ -e DB_USER=nocobase \ -e DB_PASSWORD=nocobase \ -e TZ=Asia/Shanghai ``` -------------------------------- ### Enable the simple block plugin Source: https://docs.nocobase.com/plugin-development/client/examples/custom-block Run this command to enable the @nocobase-example/plugin-simple-block plugin locally. ```bash yarn pm enable @nocobase-example/plugin-simple-block ``` -------------------------------- ### Examples: nb app autostart run Source: https://docs.nocobase.com/api/cli/app/autostart/run Runs the autostart command normally, or with --verbose to show raw startup output from the underlying local or Docker command. ```bash nb app autostart run ``` ```bash nb app autostart run --verbose ``` -------------------------------- ### Check app status with common commands Source: https://docs.nocobase.com/ai/install-nocobase-app Verify the environment is saved, the app started normally, and you can sign in with the administrator account. For a local default installation, open http://localhost:13000 in your browser. ```bash nb env list nb env info nb app logs ```