Get
Retrieves a value from the BadgerDB database by its key.
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.
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 read operation will be performed within that transaction context.
- Key - The key whose value you want to retrieve from the database.
Options
- Decoding - Specifies how to decode the stored bytes into a value:
- JSON - Decodes the value as a JSON object or array
- String - Decodes the value as a text string
- Integer - Decodes the value as a 64-bit integer
- Float - Decodes the value as a 64-bit floating point number
- Boolean - Decodes the value as a boolean (true/false)
Output
- Value - The decoded value retrieved from the database. The type depends on the Decoding option selected.
How It Works
The Get node retrieves stored data from BadgerDB by looking up a key. The stored bytes are decoded according to the specified format.
When executed, the node:
- Validates the database ID and key
- Creates a read transaction (or uses an existing one if Transaction Id is provided)
- Looks up the key in the database
- Retrieves the raw bytes stored under that key
- Decodes the bytes according to the selected Decoding option
- Returns the decoded value
Examples
Example 1: Get JSON Object
Retrieve a user profile stored as JSON:
Get
Database Id: {{db_id}}
Key: user:12345
Decoding: JSON
Output:
Value: {
"name": "John Doe",
"email": "john@example.com",
"role": "admin"
}
Example 2: Get String Value
Retrieve a simple text value:
Get
Database Id: {{db_id}}
Key: last_sync_time
Decoding: String
Output:
Value: "2025-12-23T10:30:00Z"
Example 3: Get Counter Value
Retrieve an integer counter:
Get
Database Id: {{db_id}}
Key: page_views
Decoding: Integer
Output:
Value: 1542
Example 4: Get Within Transaction
Read multiple values consistently within a transaction:
1. Start Transaction
Database Id: {{db_id}}
→ txn_id
2. Get Balance
Database Id: {{db_id}}
Transaction Id: {{txn_id}}
Key: account:balance
Decoding: Float
→ balance
3. Get Status
Database Id: {{db_id}}
Transaction Id: {{txn_id}}
Key: account:status
Decoding: String
→ status
4. Commit Transaction
Transaction Id: {{txn_id}}
Example 5: Get Boolean Flag
Retrieve a feature flag:
Get
Database Id: {{db_id}}
Key: feature:new_ui_enabled
Decoding: Boolean
Output:
Value: true
Tips for Effective Use
- Match Decoding to Storage - Use the same encoding/decoding format that was used when storing the value
- Use JSON for Complex Data - Store objects and arrays as JSON for flexibility
- Use Integers for Counters - Better performance and accuracy for numeric counters
- Cache Frequently Accessed Data - Store often-used data in BadgerDB to avoid repeated API calls
- Handle Missing Keys - Use error handling to gracefully handle keys that don't exist
- Use Transactions for Consistency - Read multiple related values in a transaction to ensure consistency
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
Get (Database Id: {{db_id}}, Key: mykey)
Error: Key Not Found
Solution: The key doesn't exist in the database. Handle this case:
Try:
Get (Key: user_settings)
Catch:
Set (Key: user_settings, Value: default_settings)
Error: "byte slice is too short to represent an int64"
Solution: The stored value was not encoded as an integer. Check:
- The value was stored using Set with Encoding: Integer
- You're using the correct key
- The data wasn't corrupted
Error: JSON Unmarshal Error
Solution: The stored value is not valid JSON. Ensure:
- The value was stored with Encoding: JSON
- The stored data is valid JSON format
- Use the correct decoding type that matches how it was stored
Error: Invalid Decoding Option
Solution: Select a valid decoding option from the dropdown:
- JSON
- String
- Integer
- Float
- Boolean
Decoding Details
JSON Decoding
- Parses JSON objects, arrays, strings, numbers, booleans, and null
- Returns the parsed JavaScript object
- Use for complex nested data structures
String Decoding
- Converts bytes directly to UTF-8 string
- Use for text data, dates, IDs, or any string content
Integer Decoding
- Decodes 64-bit signed integer stored in big-endian format
- Range: -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
- Use for counters, IDs, or whole numbers
Float Decoding
- Decodes 64-bit floating point number (IEEE 754 double precision)
- Use for decimal numbers, percentages, or measurements
Boolean Decoding
- Returns true if the first byte is non-zero
- Returns false if the first byte is zero
- Use for flags, switches, or binary states
Performance Considerations
- Read Performance - BadgerDB is optimized for fast reads
- Transaction Reads - Reading within a transaction ensures consistency but may be slightly slower
- Key Size - Shorter keys result in better performance
- Batch Reads - Use transactions to read multiple keys efficiently
Related Nodes
- Set - Stores values in the database
- Delete - Removes values from the database
- List - Lists all keys (optionally filtered by prefix)
- Start Transaction - Starts a transaction for consistent reads