List
Lists all keys in the BadgerDB database, optionally filtered by a key prefix.
Common Properties
- Name - The custom name of the node.
- Color - The custom color of the node.
- Delay Before (sec) - Waits in seconds before executing the node.
- Delay After (sec) - Waits in seconds after executing node.
- Continue On Error - Automation will continue regardless of any error. The default value is false.
info
If the ContinueOnError property is true, no error is caught when the project is executed, even if a Catch node is used.
Inputs
- Database Id - The unique identifier of the database, as returned by the Open node.
- Transaction Id - (Optional) The transaction ID from Start Transaction node. If provided, the list operation will use that transaction context.
- Prefix - (Optional) A prefix to filter keys. Only keys starting with this prefix will be returned. Leave empty to list all keys.
Output
- Keys - An array of strings containing all keys that match the prefix filter. Returns an empty array if no matching keys are found.
How It Works
The List node iterates through all keys in the database and returns those matching the optional prefix filter.
When executed, the node:
- Validates the database ID
- Retrieves the optional prefix filter
- Creates a read-only view of the database
- Iterates through keys using an iterator
- Collects keys that match the prefix (or all keys if no prefix specified)
- Returns the array of matching keys
Examples
Example 1: List All Keys
Get all keys in the database:
List
Database Id: {{db_id}}
Prefix: (empty)
Output:
Keys: [
"user:1001",
"user:1002",
"session:abc123",
"cache:api:weather",
"config:app:version"
]
Example 2: List User Keys
Get all user-related keys:
List
Database Id: {{db_id}}
Prefix: user:
Output:
Keys: [
"user:1001",
"user:1002",
"user:1003"
]
Example 3: List Session Keys
Find all active sessions:
List
Database Id: {{db_id}}
Prefix: session:
Output:
Keys: [
"session:abc123",
"session:def456",
"session:ghi789"
]
Example 4: List and Process Keys
List keys and perform operations on each:
1. List Cache Keys
Database Id: {{db_id}}
Prefix: cache:
→ cache_keys
2. For Each {{key}} in {{cache_keys}}:
Get
Database Id: {{db_id}}
Key: {{key}}
→ value
Log: {{key}} = {{value}}
Example 5: List for Bulk Delete
Find and delete all temporary keys:
1. List Temp Keys
Database Id: {{db_id}}
Prefix: temp:
→ temp_keys
2. For Each {{key}} in {{temp_keys}}:
Delete
Database Id: {{db_id}}
Key: {{key}}
Example 6: Hierarchical Prefixes
Use nested prefixes for organization:
List User Settings
Database Id: {{db_id}}
Prefix: user:1001:settings:
Output:
Keys: [
"user:1001:settings:theme",
"user:1001:settings:language",
"user:1001:settings:notifications"
]
Tips for Effective Use
- Use Descriptive Prefixes - Structure keys hierarchically (e.g., "user🆔", "cache:api:")
- Colon Separators - Use colons to separate prefix levels for clarity
- Empty Prefix Lists All - Omit prefix to retrieve all keys in the database
- Process in Batches - For large result sets, process keys in batches
- Combine with Get - Use List to find keys, then Get to retrieve values
- Combine with Delete - Use List for bulk deletion operations
- Use Consistent Naming - Maintain consistent key naming conventions
Common Errors and Solutions
Error: "Database ID cannot be empty"
Solution: Ensure you're passing a valid database ID from the Open node.
Correct:
Open → db_id
List (Database Id: {{db_id}})