### Simulating Quickstart Process Source: https://github.com/nocobase/docs/blob/main/docs/fr-FR/development/server/test.md Use `runCommand('start', '--quickstart')` to simulate the quickstart process, which handles automatic installation or upgrades before starting the application. ```typescript const app = mockServer(); await app.runCommand('start', '--quickstart'); ``` -------------------------------- ### Simulating Install then Start Process Source: https://github.com/nocobase/docs/blob/main/docs/fr-FR/development/server/test.md This snippet demonstrates how to programmatically simulate the 'install' and 'start' commands using `mockServer` and `runCommand` for testing installation and startup flows. ```typescript const app = mockServer(); await app.runCommand('install'); await app.runCommand('start'); ``` -------------------------------- ### Simulating Reinstalling an Application Source: https://github.com/nocobase/docs/blob/main/docs/fr-FR/development/server/test.md This example shows how to simulate reinstalling an already installed and started application using `runCommand('start', '--quickstart')` followed by `runCommand('install', '-f')` to force reinstallation. ```typescript const app = mockServer(); await app.runCommand('start', '--quickstart'); await app.runCommand('install', '-f'); ``` -------------------------------- ### Test Quickstart Command Source: https://github.com/nocobase/docs/blob/main/docs/en-US/development/server/test.md Demonstrates testing the 'start --quickstart' command using mockServer. This simulates an automatic install or upgrade process during startup. ```bash yarn start --quickstart ``` ```typescript const app = mockServer(); await app.runCommand('start', '--quickstart'); ``` -------------------------------- ### Simulating Start then Install Process Source: https://github.com/nocobase/docs/blob/main/docs/fr-FR/development/server/test.md This code simulates starting the server first, then running the install command, useful for testing scenarios where installation occurs after the server has begun its process. ```typescript const app = mockServer(); await app.runCommand('start'); await app.runCommand('install'); ``` -------------------------------- ### Test Start then Install Command Source: https://github.com/nocobase/docs/blob/main/docs/en-US/development/server/test.md Simulates running 'start' followed by 'install' using mockServer. This tests scenarios where installation commands are executed after the application has already started. ```bash yarn start # Stay in memory # Execute in another terminal yarn nocobase install ``` ```typescript const app = mockServer(); await app.runCommand('start'); await app.runCommand('install'); ``` -------------------------------- ### Test Install then Start Command Source: https://github.com/nocobase/docs/blob/main/docs/en-US/development/server/test.md Simulates the 'install' and 'start' commands using mockServer. This is useful for testing the application's installation and startup sequence in a controlled environment. ```bash yarn nocobase install yarn start ``` ```typescript const app = mockServer(); await app.runCommand('install'); await app.runCommand('start'); ``` -------------------------------- ### NocoBase Initial Installation Examples Source: https://github.com/nocobase/docs/blob/main/docs/en-US/api/cli.md Provides examples for performing an initial installation of NocoBase, including specifying language, root email, and password. Also shows options for force reinstallation and database clearing. ```bash # Initial installation yarn nocobase install -l zh-CN -e admin@nocobase.com -p admin123 # Delete all data tables from NocoBase and reinstall yarn nocobase install -f -l zh-CN -e admin@nocobase.com -p admin123 # Clear database and reinstall yarn nocobase install -c -l zh-CN -e admin@nocobase.com -p admin123 ``` -------------------------------- ### Test Reinstall Application Source: https://github.com/nocobase/docs/blob/main/docs/en-US/development/server/test.md Shows how to test reinstalling an already installed and started application using mockServer. This involves running 'start --quickstart' followed by 'install -f'. ```bash yarn start --quickstart # Execute in another terminal yarn nocobase install -f ``` ```typescript const app = mockServer(); await app.runCommand('start', '--quickstart'); await app.runCommand('install', '-f'); ``` -------------------------------- ### Simulating Application Upgrade (Before Starting) Source: https://github.com/nocobase/docs/blob/main/docs/fr-FR/development/server/test.md Demonstrates simulating an application upgrade before starting it, using `runCommand('upgrade', '-f')` followed by `runCommand('start', '--quickstart')`. ```typescript const app = mockServer(); await app.runCommand('upgrade', '-f'); await app.runCommand('start', '--quickstart'); ``` -------------------------------- ### Simulating Application Upgrade (After Starting) Source: https://github.com/nocobase/docs/blob/main/docs/fr-FR/development/server/test.md This snippet simulates upgrading an application after it has already started, by first running `start --quickstart` and then `upgrade -f`. ```typescript const app = mockServer(); await app.runCommand('start', '--quickstart'); await app.runCommand('upgrade', '-f'); ``` -------------------------------- ### Initialize Nocobase App and Install Plugin Source: https://github.com/nocobase/docs/blob/main/docs/en-US/plugin-samples/router/add-setting-page-layout-routes/index.md Commands to create a new Nocobase application, install dependencies, install Nocobase, create a new plugin, enable it, and start the development server. ```bash yarn create nocobase-app my-nocobase-app -d postgres cd my-nocobase-app yarn install yarn nocobase install ``` ```bash yarn pm create @nocobase-sample/plugin-add-setting-page-layout-routes yarn pm enable @nocobase-sample/plugin-add-setting-page-layout-routes ``` ```bash yarn dev ``` -------------------------------- ### Build and Start NocoBase for Production Source: https://github.com/nocobase/docs/blob/main/docs/en-US/welcome/getting-started/installation/git-clone.md Build the NocoBase application for production and then start the production server. Ensure dependencies are installed with `yarn install --frozen-lockfile` before building. ```bash yarn build yarn start ``` -------------------------------- ### Test Upgrade Application (After Starting) Source: https://github.com/nocobase/docs/blob/main/docs/en-US/development/server/test.md Demonstrates testing an application upgrade after it has already started, using mockServer. This involves running 'start --quickstart' and then 'upgrade -f'. ```bash yarn start # Stay in memory # Execute in another terminal yarn nocobase upgrade ``` ```typescript const app = mockServer(); await app.runCommand('start', '--quickstart'); await app.runCommand('upgrade', '-f'); ``` -------------------------------- ### NocoBase Install Command Usage Source: https://github.com/nocobase/docs/blob/main/docs/en-US/api/cli.md Lists options for the `install` command, which is used for initial setup and installation of NocoBase. ```bash $ yarn nocobase install -h Usage: nocobase install [options] Options: -f, --force -c, --clean -s, --silent -l, --lang [lang] -e, --root-email -p, --root-password -n, --root-nickname [rootNickname] -h, --help ``` -------------------------------- ### Initialize Plugin and Application Source: https://github.com/nocobase/docs/blob/main/docs/en-US/plugin-samples/router/add-page/index.md Commands to create, install, and enable a Nocobase plugin, followed by starting the development server. ```bash yarn create nocobase-app my-nocobase-app -d postgres cd my-nocobase-app yarn install yarn nocobase install yarn pm create @nocobase-sample/plugin-add-page yarn pm enable @nocobase-sample/plugin-add-page yarn dev ``` -------------------------------- ### createMockServer() Source: https://github.com/nocobase/docs/blob/main/docs/fr-FR/api/test/server.md Create, install, and start a MockServer instance. ```APIDOC ## createMockServer() ### Description Create a `MockServer` instance, perform forced installation, and start it. ### Signature ```ts createMockServer(options?: ApplicationOptions & { version?: string; beforeInstall?: BeforeInstallFn; skipInstall?: boolean; skipStart?: boolean; }): Promise ``` ### Parameters #### Path Parameters - `options` (ApplicationOptions) - Required - Refer to [Application](../server/application.md) - `options.version` (string) - Optional - Application version - `options.beforeInstall` (BeforeInstallFn) - Optional - Function to execute before installation - `options.skipInstall` (boolean) - Optional - Whether to skip forced installation - `options.skipStart` (boolean) - Optional - Whether to skip application startup ``` -------------------------------- ### Install and Enable Plugin Source: https://github.com/nocobase/docs/blob/main/docs/en-US/plugin-samples/schema-initializer/block-data-modal.md Steps to create and enable a NocoBase plugin for the data block modal example. ```bash yarn create nocobase-app my-nocobase-app -d postgres cd my-nocobase-app yarn install yarn nocobase install ``` ```bash yarn pm create @nocobase-sample/plugin-initializer-block-data-modal yarn pm enable @nocobase-sample/plugin-initializer-block-data-modal yarn dev ``` -------------------------------- ### Starting NocoBase in Development Mode Source: https://github.com/nocobase/docs/blob/main/docs/en-US/api/cli.md Examples of using the `dev` command to launch the application for development, including options to start only the server or client. ```bash # Launch application for development environment, with real-time compilation yarn nocobase dev # Start the server side only yarn nocobase dev --server # Start the client side only yarn nocobase dev --client ``` -------------------------------- ### Install and Start NocoBase with Docker Compose Source: https://github.com/nocobase/docs/blob/main/docs/fr-FR/welcome/getting-started/installation/docker-compose.md Use these commands to pull the necessary Docker images and start the NocoBase services in the background. View application logs to monitor the startup process. ```bash docker-compose pull ``` ```bash docker-compose up -d ``` ```bash docker-compose logs app ``` -------------------------------- ### Get Detail Response Example Source: https://github.com/nocobase/docs/blob/main/docs/en-US/development/http-api/index.md Example of a successful response when retrieving a single resource's details. ```bash GET /api/posts:get/1 Response 200 (application/json) { data: { id: 1 }, } ``` -------------------------------- ### Start Application Options Type Source: https://github.com/nocobase/docs/blob/main/docs/en-US/api/server/application.md Defines the options for starting the application. The `checkInstall` option determines if an installation check should be performed. ```typescript interface StartOptions { checkInstall?: boolean; } ``` -------------------------------- ### Initialize NocoBase App and Plugin Source: https://github.com/nocobase/docs/blob/main/docs/en-US/plugin-samples/field/value.md Commands to create a new NocoBase application, install dependencies, install the plugin, enable it, and start the development server. ```bash yarn create nocobase-app my-nocobase-app -d postgres cd my-nocobase-app yarn install yarn nocobase install ``` ```bash yarn pm create @nocobase-sample/plugin-field-value yarn pm enable @nocobase-sample/plugin-field-value ``` ```bash yarn dev ``` -------------------------------- ### Mock Server Setup and Test Source: https://github.com/nocobase/docs/blob/main/docs/en-US/development/server/test.md Illustrates setting up a mock server application for testing HTTP APIs. It includes helper functions for creating and starting the app, and beforeEach/afterEach hooks for managing the application lifecycle during tests. ```typescript import { MockServer, mockServer } from '@nocobase/test'; // Each plugin's minimal installation app is different, the necessary plugins need to be added according to their own conditions. async function createApp(options: any = {}) { const app = mockServer({ ...options, plugins: [ 'acl', 'users', 'collection-manager', 'error-handler', ...options.plugins, ], // Other configuration parameters might also be present. }); // Here, some logic that needs special handling can be supplemented, such as importing data tables needed for testing. return app; } // Most tests need to start the application, so a common startup method can also be provided. async function startApp() { const app = createApp(); await app.quickstart({ // Before running tests, clear the database. clean: true, }); return app; } describe('test example', () => { let app: MockServer; beforeEach(async () => { app = await startApp(); }); afterEach(async () => { // After running the tests, clear the database. await app.destroy(); // Stop without clearing the database. await app.stop(); }); test('case1', async () => { // coding... }); }); ``` -------------------------------- ### Test Upgrade Application (Before Starting) Source: https://github.com/nocobase/docs/blob/main/docs/en-US/development/server/test.md Tests the process of upgrading an application before it starts, using mockServer. It simulates running 'upgrade -f' followed by 'start --quickstart'. ```bash yarn nocobase upgrade yarn start ``` ```typescript const app = mockServer(); await app.runCommand('upgrade', '-f'); await app.runCommand('start', '--quickstart'); ``` -------------------------------- ### Installation (`install`) Source: https://github.com/nocobase/docs/blob/main/docs/en-US/api/cli.md Installs NocoBase, optionally with force or clean options, and allows setting initial administrator credentials and language. ```APIDOC ## `install` Command Installs NocoBase. ### Usage ```bash $ yarn nocobase install [options] ``` ### Options - `-f, --force`: Delete all data tables from NocoBase and reinstall. - `-c, --clean`: Clear the entire database and reinstall. - `-s, --silent`: Run in silent mode. - `-l, --lang [lang]`: Set the installation language (e.g., `zh-CN`). - `-e, --root-email `: Set the root administrator's email. - `-p, --root-password `: Set the root administrator's password. - `-n, --root-nickname [rootNickname]`: Set the root administrator's nickname. - `-h, --help`: Display help information. ### Example ```bash # Initial installation yarn nocobase install -l zh-CN -e admin@nocobase.com -p admin123 # Delete all data tables from NocoBase and reinstall yarn nocobase install -f -l zh-CN -e admin@nocobase.com -p admin123 # Clear database and reinstall yarn nocobase install -c -l zh-CN -e admin@nocobase.com -p admin123 ``` ### Force vs Clean - `-f/--force`: Deletes only NocoBase's data tables. - `-c/--clean`: Clears the entire database, deleting all tables. ``` -------------------------------- ### createMockServer Source: https://github.com/nocobase/docs/blob/main/docs/en-US/api/test/server.md Creates and starts a MockServer instance, performing forced installation. ```APIDOC ## createMockServer(options?: ApplicationOptions & { version?: string; beforeInstall?: BeforeInstallFn; skipInstall?: boolean; skipStart?: boolean; }): Promise ### Description Create a `MockServer` instance, perform forced installation, and start it. ### Signature ```ts createMockServer(options?: ApplicationOptions & { version?: string; beforeInstall?: BeforeInstallFn; skipInstall?: boolean; skipStart?: boolean; }): Promise ``` ### Parameters #### Path Parameters - `options` (ApplicationOptions) - Required - Refer to [Application](../server/application.md) - `options.version` (string) - Optional - Application version - `options.beforeInstall` (BeforeInstallFn) - Optional - Function to execute before installation - `options.skipInstall` (boolean) - Optional - Whether to skip forced installation - `options.skipStart` (boolean) - Optional - Whether to skip application startup ``` -------------------------------- ### Initialize NocoBase App and Install Plugin Source: https://github.com/nocobase/docs/blob/main/docs/en-US/plugin-samples/schema-initializer/action-simple.md These commands set up a new NocoBase application, install dependencies, and enable a specific plugin. Ensure you have Node.js and Yarn installed. ```bash yarn create nocobase-app my-nocobase-app -d postgres cd my-nocobase-app yarn install yarn nocobase install ``` ```bash yarn pm create @nocobase-sample/plugin-initializer-action-simple yarn pm enable @nocobase-sample/plugin-initializer-action-simple ``` ```bash yarn dev ``` -------------------------------- ### Test Activate Plugin Source: https://github.com/nocobase/docs/blob/main/docs/en-US/development/server/test.md Shows how to test activating a plugin using mockServer. It simulates starting the app with quickstart and then enabling a specific plugin. ```bash yarn start --quickstart yarn pm enable @my-project/plugin-hello ``` ```typescript const app = mockServer(); await app.runCommand('start', '--quickstart'); await app.runCommand('pm', 'enable', '@my-project/plugin-hello'); ``` -------------------------------- ### Simulating Plugin Activation Source: https://github.com/nocobase/docs/blob/main/docs/fr-FR/development/server/test.md Use `runCommand` to simulate activating a plugin. This involves starting the application with quickstart and then enabling the specified plugin using `pm enable`. ```typescript const app = mockServer(); await app.runCommand('start', '--quickstart'); await app.runCommand('pm', 'enable', '@my-project/plugin-hello'); ``` -------------------------------- ### Collection Resource Request Examples Source: https://github.com/nocobase/docs/blob/main/docs/en-US/api/http/index.md Illustrates common HTTP requests for managing 'posts' collection resources, including create, list, get, update, and destroy actions. ```bash POST /api/posts:create GET /api/posts:list GET /api/posts:get/1 POST /api/posts:update/1 POST /api/posts:destroy/1 ``` -------------------------------- ### Create LibreOffice Installation Script Source: https://github.com/nocobase/docs/blob/main/docs/ja-JP/handbook/action-template-print/install.md Create a shell script to automate the installation of LibreOffice. This script handles dependencies, downloading, and installation. ```bash mkdir ./storage/scripts cd ./storage/scripts vim install-libreoffice.sh ``` ```sh #!/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." ``` -------------------------------- ### Create LibreOffice Installation Script Source: https://github.com/nocobase/docs/blob/main/docs/en-US/handbook/action-template-print/install.md Creates a directory for custom scripts and opens a file for the LibreOffice installation script. This script automates the download and installation of LibreOffice. ```bash mkdir ./storage/scripts cd ./storage/scripts vim install-libreoffice.sh ``` -------------------------------- ### Action Examples Source: https://github.com/nocobase/docs/blob/main/docs/en-US/development/http-api/index.md Examples of available actions that can be performed on resources. ```APIDOC ## Action Types Actions are denoted with `:` and can be applied to resources or associations. ### Global Actions (for collections or associations): - `create` - `get` - `list` - `update` - `destroy` - `move` ### Association Actions (only for associations): - `set` - `add` - `remove` - `toggle` ### Examples - `posts:create` (Create an article) - `posts.user:get` (Get the article's user) - `posts.tags:add` (Add tags to an article) ``` -------------------------------- ### start() Source: https://github.com/nocobase/docs/blob/main/docs/en-US/api/telemetry/telemetry.md Starts the processing of Trace and Metric related data, such as exporting to Prometheus. ```APIDOC ## start() ### Description Begins the active processing and exporting of collected trace and metric data. ### Method `start` ### Endpoint None (This is a method call) ### Parameters None ### Request Example ```javascript telemetry.start(); ``` ### Response #### Success Response (200) None (This method does not return a value) #### Response Example None ``` -------------------------------- ### Initialize Plugin and Install Dependencies Source: https://github.com/nocobase/docs/blob/main/docs/en-US/plugin-samples/schema-initializer/block-simple.md Steps to create a new NocoBase app, install dependencies, and enable a sample plugin. ```bash yarn create nocobase-app my-nocobase-app -d postgres cd my-nocobase-app yarn install yarn nocobase install ``` ```bash yarn pm create @nocobase-sample/plugin-initializer-block-simple yarn pm enable @nocobase-sample/plugin-initializer-block-simple yarn dev ``` -------------------------------- ### Initialize NocoBase Project and Install Plugin Source: https://github.com/nocobase/docs/blob/main/docs/en-US/plugin-samples/schema-initializer/block-data.md Steps to create a new NocoBase application, install dependencies, and enable a custom plugin. ```bash yarn create nocobase-app my-nocobase-app -d postgres cd my-nocobase-app yarn install yarn nocobase install ``` ```bash yarn pm create @nocobase-sample/plugin-initializer-block-data yarn pm enable @nocobase-sample/plugin-initializer-block-data ``` ```bash yarn dev ``` -------------------------------- ### Initialize Nocobase App and Install Plugin Source: https://github.com/nocobase/docs/blob/main/docs/fr-FR/plugin-samples/router/add-setting-page-tabs-routes/index.md Steps to create a new Nocobase application, install dependencies, and enable a specific plugin. ```bash yarn create nocobase-app my-nocobase-app -d postgres cd my-nocobase-app yarn install yarn nocobase install ``` ```bash yarn pm create @nocobase-sample/plugin-add-setting-page-tabs-routes yarn pm enable @nocobase-sample/plugin-add-setting-page-tabs-routes ``` ```bash yarn dev ``` -------------------------------- ### Get single post response example Source: https://github.com/nocobase/docs/blob/main/docs/en-US/api/http/index.md Example of a successful response when retrieving a single post by its ID. ```bash GET /api/posts:get/1 Response 200 (application/json) { data: { id: 1 } } ``` -------------------------------- ### Basic Mock Server Setup Source: https://github.com/nocobase/docs/blob/main/docs/en-US/api/test/server.md Sets up a mock server instance with specified plugins for server-side testing. Ensure to destroy the app after tests. ```typescript describe('actions', () => { let app: MockServer; let db: Database; let agent: any; beforeAll(async () => { app = await createMockServer({ plugins: ['acl', 'users', 'data-source-manager'], }); db = app.db; agent = app.agent(); }); afterAll(async () => { await app.destroy(); }); }); ``` -------------------------------- ### Basic APIClient Request Example Source: https://github.com/nocobase/docs/blob/main/docs/en-US/development/client/api-client.md A simple example of using `apiClient.request()` to make a GET request to a specified URL. ```typescript const response = await apiClient.request({ url }); ``` -------------------------------- ### Example Client Request for List Action Source: https://github.com/nocobase/docs/blob/main/docs/en-US/development/server/resources-actions.md Demonstrates how a client can add parameters to a URL to query orders, which will be merged with default action parameters. ```bash curl 'http://localhost:13000/api/orders:list?productId=1&fields=id,status,quantity,totalPrice&appends=product' ``` -------------------------------- ### Get Tracer and Start Spans Source: https://github.com/nocobase/docs/blob/main/docs/en-US/development/server/telemetry.md Acquire a tracer from the telemetry app and start active or regular spans. This is used for trace collection. ```ts const tracer = app.telemetry.trace.getTracer(); tracer.startActiveSpan(); tracer.startSpan(); ``` -------------------------------- ### Initialize Nocobase App and Install Plugin Source: https://github.com/nocobase/docs/blob/main/docs/en-US/plugin-samples/provider/content.md Commands to create a new Nocobase application, install dependencies, and enable a specific plugin. ```bash yarn create nocobase-app my-nocobase-app -d postgres cd my-nocobase-app yarn install yarn nocobase install ``` ```bash yarn pm create @nocobase-sample/plugin-provider-content yarn pm enable @nocobase-sample/plugin-provider-content ``` ```bash yarn dev ``` -------------------------------- ### Resource Actions Source: https://github.com/nocobase/docs/blob/main/docs/fr-FR/api/http/index.md Examples of common actions on resources, including create, list, get, update, and destroy. ```APIDOC ## Resource Actions Examples ### Posts Resource - `POST /api/posts:create` - Create a new post. - `GET /api/posts:list` - Retrieve a list of posts. - `GET /api/posts:get/1` - Retrieve a specific post by its index. - `POST /api/posts:update/1` - Update a specific post by its index. - `POST /api/posts:destroy/1` - Delete a specific post by its index. ### Posts Comments Resource - `POST /api/posts/1/comments:create` - Create a new comment for a post. - `GET /api/posts/1/comments:list` - Retrieve a list of comments for a post. - `GET /api/posts/1/comments:get/1` - Retrieve a specific comment by its index. - `POST /api/posts/1/comments:update/1` - Update a specific comment by its index. - `POST /api/posts/1/comments:destroy/1` - Delete a specific comment by its index. ### Posts Tags Resource - `POST /api/posts/1/tags:create` - Create a tag association for a post. - `GET /api/posts/1/tags:get` - Retrieve tags associated with a post. - `GET /api/posts/1/tags:list` - List tags associated with a post. - `POST /api/posts/1/tags:update` - Update tag associations for a post. - `POST /api/posts/1/tags:destroy` - Remove tag associations for a post. - `POST /api/posts/1/tags:add` - Add existing tags to a post. - `GET /api/posts/1/tags:remove` - Remove tags from a post. ``` -------------------------------- ### Dockerfile for MariaDB Client Installation Source: https://github.com/nocobase/docs/blob/main/docs/en-US/handbook/backups/installation/mariadb.md This Dockerfile installs the MySQL client core components by downloading a specific .deb package and copying the necessary binaries. It's designed to be used with NocoBase's Docker setup. ```Dockerfile # Based on the "next" version FROM nocobase/nocobase:latest # Update sources.list with the official Debian repositories RUN tee /etc/apt/sources.list > /dev/null < {{after array 1}} ``` -------------------------------- ### NocoBase Start Command Usage Source: https://github.com/nocobase/docs/blob/main/docs/en-US/api/cli.md Displays options for the `start` command, used to run the application in a production environment after building. ```bash $ yarn nocobase start -h Usage: nocobase start [options] Options: -p, --port -s, --silent -h, --help ``` -------------------------------- ### NocoBase CLI Commands Overview Source: https://github.com/nocobase/docs/blob/main/docs/en-US/api/cli.md Lists the primary commands available in the NocoBase CLI, including console, database operations, installation, starting, building, and testing. ```bash yarn nocobase console yarn nocobase db:auth yarn nocobase db:sync yarn nocobase install yarn nocobase start yarn nocobase build yarn nocobase clean yarn nocobase dev yarn nocobase doc yarn nocobase test yarn nocobase umi yarn nocobase upgrade yarn nocobase migrator yarn nocobase pm yarn nocobase help ``` -------------------------------- ### Full Example with Memory Router Source: https://github.com/nocobase/docs/blob/main/docs/en-US/api/client/router.md Demonstrates setting up a memory router with initial entries and defining nested routes for a layout, home, and about page. ```tsx /** * defaultShowCode: true */ import React from 'react'; import { Link, Outlet } from 'react-router-dom'; import { Application } from '@nocobase/client'; const Home = () =>

Home

; const About = () =>

About

; const Layout = () => { return (
Home, About
); }; const app = new Application({ router: { type: 'memory', initialEntries: ['/'], }, }); app.router.add('root', { element: , }); app.router.add('root.home', { path: '/', element: , }); app.router.add('root.about', { path: '/about', element: , }); export default app.getRootComponent(); ``` -------------------------------- ### Build Plugin Step-by-Step Source: https://github.com/nocobase/docs/blob/main/docs/en-US/development/your-fisrt-plugin.md Alternatively, build your plugin and then create a tarball in separate steps. ```bash # step by step yarn build @my-project/plugin-hello yarn nocobase tar @my-project/plugin-hello ``` -------------------------------- ### Define a Custom Server Command Source: https://github.com/nocobase/docs/blob/main/docs/en-US/development/server/commands.md Example of defining a custom command named 'echo' with an option to display the version. Custom commands are effective after plugin installation and activation. ```typescript import { Application } from '@nocobase/server'; export default function(app: Application) { app .command('echo') .option('-v, --version') .action(async ([options]) => { console.log('Hello World!'); if (options.version) { console.log('Current version:', await app.version.get()); } }); } ``` -------------------------------- ### Serve Documentation Source: https://github.com/nocobase/docs/blob/main/docs/en-US/api/cli.md Serves the built documentation for viewing. Specify the language with --lang. ```bash yarn doc serve --lang=zh-CN ``` -------------------------------- ### Create Migration Command Help Source: https://github.com/nocobase/docs/blob/main/docs/en-US/development/server/migration.md Displays help information for the `create-migration` command, including available options. ```bash yarn nocobase create-migration -h ``` -------------------------------- ### View Data in Plugin Collection via API Source: https://github.com/nocobase/docs/blob/main/docs/en-US/development/your-fisrt-plugin.md Use `curl` to send a GET request to list data from your plugin's collection. This example retrieves all records from the 'hello' collection. ```bash curl --location --request GET 'http://localhost:13000/api/hello:list' ``` -------------------------------- ### Install and Enable Plugin Source: https://github.com/nocobase/docs/blob/main/docs/en-US/plugin-samples/provider/context.md Commands to create, install, and enable a NocoBase plugin. Ensure your project is set up and running. ```bash yarn create nocobase-app my-nocobase-app -d postgres cd my-nocobase-app yarn install yarn nocobase install ``` ```bash yarn pm create @nocobase-sample/plugin-provider-context yarn pm enable @nocobase-sample/plugin-provider-context ``` ```bash yarn dev ``` -------------------------------- ### Create and Use Named Cache Instances Source: https://context7.com/nocobase/docs/llms.txt Create named cache instances with specific stores, prefixes, and configurations. Examples show setting, getting, wrapping, deleting, and resetting cache entries. ```typescript // ── Create named caches ──────────────────────────────────────────────────────── const defaultCache = await cacheManager.createCache({ name: 'default', store: 'memory', prefix: 'app', max: 2000, }); const sessionCache = await cacheManager.createCache({ name: 'sessions', store: 'redis', prefix: 'sess', ttl: 86400, }); // ── Use a Cache instance ─────────────────────────────────────────────────────── // Get / set await defaultCache.set('user:1', { id: 1, name: 'Alice' }, 300); // TTL 5 min const user = await defaultCache.get('user:1'); // { id: 1, name: 'Alice' } // Get-or-set pattern const profile = await defaultCache.wrap('profile:1', async () => { return db.getRepository('users').findOne({ filterByTk: 1 }); }, 600); // Delete await defaultCache.del('user:1'); // Flush the entire namespace await defaultCache.reset(); ``` -------------------------------- ### Association Resource Request Examples (posts.tags) Source: https://github.com/nocobase/docs/blob/main/docs/en-US/api/http/index.md Shows HTTP requests for managing 'tags' association resource for 'posts', including create, get, list, update, destroy, add, and remove actions. ```bash POST /api/posts/1/tags:create GET /api/posts/1/tags:get GET /api/posts/1/tags:list POST /api/posts/1/tags:update POST /api/posts/1/tags:destroy POST /api/posts/1/tags:add GET /api/posts/1/tags:remove ``` -------------------------------- ### Install and Run NocoBase V1 Docs Locally Source: https://github.com/nocobase/docs/blob/main/README.md Clone the repository, install dependencies, and run the development server for English, Chinese, French, Japanese, or Russian documentation. Note that English and Chinese development servers cannot run simultaneously. ```bash git clone https://github.com/nocobase/docs.git cd docs yarn install # Run English docs yarn dev:en # Run Chinese docs yarn dev # Run French docs yarn dev:fr # Run Japanese docs yarn dev:ja # Run Russian docs yarn dev:ru ``` -------------------------------- ### Association Resource Request Examples (posts.comments) Source: https://github.com/nocobase/docs/blob/main/docs/en-US/api/http/index.md Demonstrates HTTP requests for managing 'comments' association resource within the 'posts' collection, covering create, list, get, update, and destroy actions. ```bash POST /api/posts/1/comments:create GET /api/posts/1/comments:list GET /api/posts/1/comments:get/1 POST /api/posts/1/comments:update/1 POST /api/posts/1/comments:destroy/1 ``` -------------------------------- ### Preview Documentation Source: https://github.com/nocobase/docs/blob/main/docs/en-US/welcome/community/contributing.md Commands to start the documentation preview server for different languages. The documentation files are located in the /docs directory. ```bash yarn doc --lang=zh-CN ``` ```bash yarn doc --lang=en-US ``` -------------------------------- ### Get Specific Path Segments with segments Source: https://github.com/nocobase/docs/blob/main/docs/en-US/api/handlebars-helpers/path.md The `segments` helper allows you to extract and join specific segments of a file path by providing start and end indices. It's useful for accessing parts of a nested path. ```handlebars {{segments "a/b/c/d" "2" "3"}} ``` ```handlebars {{segments "a/b/c/d" "1" "3"}} ``` ```handlebars {{segments "a/b/c/d" "1" "2"}} ``` -------------------------------- ### Add and Get Middleware Handler Source: https://github.com/nocobase/docs/blob/main/docs/en-US/api/resourcer/middleware.md Demonstrates adding an additional middleware function using `use()` and then retrieving the orchestrated handler with `getHandler()` to be applied to the app's resourcer. This example shows sequential execution of middleware. ```typescript const middleware = new Middleware((ctx, next) => { console.log(1); await next(); }); middleware.use(async (ctx, next) => { console.log(2); await next(); }); app.resourcer.use(middleware.getHandler()); ```