From b0de46395a8eb9492fa4570519a6905935446295 Mon Sep 17 00:00:00 2001 From: Joonsoo Park Date: Sat, 12 Oct 2024 16:45:34 +0900 Subject: [PATCH] docs: audit and make documentation for command SELECT (#1041) --- docs/src/content/docs/commands/SELECT.md | 45 ++++++++++++------------ 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/docs/src/content/docs/commands/SELECT.md b/docs/src/content/docs/commands/SELECT.md index 60555a55d..69d4409c3 100644 --- a/docs/src/content/docs/commands/SELECT.md +++ b/docs/src/content/docs/commands/SELECT.md @@ -3,20 +3,27 @@ title: SELECT description: Documentation for the DiceDB command SELECT --- +**Note:** As of today, DiceDB does not support multiple databases. Therefore, the `SELECT` command is currently a dummy method and does not affect the database. It remains as a placeholder. + The `SELECT` command is used to switch the currently selected database for the current connection in DiceDB. By default, DiceDB starts with database 0, but it supports multiple databases, which can be accessed by using the `SELECT` command. This command is essential for managing data across different logical databases within a single DiceDB instance. -## Parameters +## Syntax -### index +``` +SELECT index +``` -- `Type`: Integer -- `Description`: The zero-based index of the database to select. DiceDB databases are indexed starting from 0 up to a configurable maximum (default is 15, configurable via the `databases` configuration directive). -- `Constraints`: Must be a non-negative integer within the range of available databases. +## Parameters + +| Parameter | Description | Type | Required | +|-----------|-------------------------------------------------|---------|----------| +| `index` | The zero-based index of the database to select. DiceDB databases are indexed starting from 0 up to a configurable maximum (default is 15, configurable via the `databases` configuration directive) | Integer | Yes | ## Return Value -- `Type`: Simple String -- `Description`: Returns `OK` if the database switch was successful. +| Condition | Return Value | +|--------------------------|--------------| +| Command is successful | `OK` | ## Behaviour @@ -24,10 +31,11 @@ When the `SELECT` command is issued, the current connection's context is switche - `Initial State`: By default, the connection starts with database 0. - `Post-Command State`: The connection will be associated with the specified database index. +- The number of databases is configurable in the DiceDB configuration file (`DiceDB.conf`) using the `databases` directive. +- Switching databases does not affect the data stored in other databases; it only changes the context for the current connection. +- The `SELECT` command is connection-specific. Different connections can operate on different databases simultaneously. -## Error Handling - -The `SELECT` command can raise errors under the following conditions: +## Errors 1. `Invalid Database Index`: @@ -44,7 +52,7 @@ The `SELECT` command can raise errors under the following conditions: ### Switching to Database 1 ```shell -127.0.0.1:6379> SELECT 1 +127.0.0.1:7379> SELECT 1 OK ``` @@ -53,7 +61,7 @@ In this example, the connection switches to database 1. All subsequent commands ### Switching to Database 0 ```shell -127.0.0.1:6379> SELECT 0 +127.0.0.1:7379> SELECT 0 OK ``` @@ -62,7 +70,7 @@ Here, the connection switches back to the default database 0. ### Error Example: Invalid Database Index ```shell -127.0.0.1:6379> SELECT 16 +127.0.0.1:7379> SELECT 16 (error) ERR DB index is out of range ``` @@ -71,17 +79,8 @@ In this example, an error is raised because the specified database index 16 is o ### Error Example: Non-Integer Index ```shell -127.0.0.1:6379> SELECT one +127.0.0.1:7379> SELECT one (error) ERR value is not an integer or out of range ``` In this example, an error is raised because the provided index is not a valid integer. - -## Notes - -- The number of databases is configurable in the DiceDB configuration file (`DiceDB.conf`) using the `databases` directive. -- Switching databases does not affect the data stored in other databases; it only changes the context for the current connection. -- The `SELECT` command is connection-specific. Different connections can operate on different databases simultaneously. - -By understanding and using the `SELECT` command, you can efficiently manage and segregate data across multiple logical databases within a single DiceDB instance. -