Table State Operations
The State provider has table operations for storing state.
Set Table Values
Using a table name, you can store key-value pairs for retrieval later.
Method Signature
Setting Table Values
session = vcr.createSession()
state = State(session)
customer = body['customer']
number = customer['number']
await state.mapSet('customers', { number: customer })
Increment Table Values
Using a table name and key, you can increment its value.
Method Signature
Incrementing Table Values
number = body['number']
await state.mapIncrement('customers', number, 1)
Get a Table Value
Using a table name and key, you can fetch a value.
Method Signature
Getting a Table Value
number = body['number']
customer = await state.mapGetValue('customers', number)
Getting Multiple Table Values
Using a table name and an array of keys, you can fetch multiple values.
Method Signature
Getting Multiple Table Values
number = body['number']
otherNumber = '447000000001'
customer = await state.mapGetMultiple('customers', [number, otherNumber])
Scan Table Values
By providing a pattern you can scan a table, starting at a specified cursor.
Method Signature
Scanning Table Values
name = body['name']
await state.mapScan('customers', '0', name, 0)
Getting All Table Values
Using a table name, you can fetch all the stored values.
Method Signature
Getting All Table Values
customers = await state.mapGetValues('customers')
Get a Table
Using a table name, you can fetch the entire table.
Method Signature
Getting a Table
customerNumberPairs = await state.mapGetAll('customers')
Get a Table's Length
Using a table name, you can fetch the length of the table.
Method Signature
Getting a Table's Length
tableLength = await state.mapLength('customers')
Check a Table Key Exists
Using a table name and key, you can check if a key exists on a table.
Method Signature
Checking a Table Key Exists
number = body['number']
isExistingCustomer = await state.mapExists('customers', number)
Delete Table Values
Using a table name and a list of keys, you can delete a values.
Method Signature
Deleting Table Values
number = body['number']
await state.mapDelete('customers', [number])
Delete a Table
Using a table name, you can delete the whole table.
Method Signature
Deleting a Table
await state.delete('customers')