persist.redis
Module persist.redis
API
ballerinax/persist.redis Ballerina library
Functions
getAlreadyExistsError
Generates a new persist:AlreadyExistsError
with the given parameters.
Return Type
- AlreadyExistsError - The generated
persist:AlreadyExistsError
getConstraintViolationError
function getConstraintViolationError(string entity, string refEntity) returns ConstraintViolationError
Generates a new persist:ConstraintViolationError
with the given parameters.
Return Type
- ConstraintViolationError - The generated
persist:ConstraintViolationError
Classes
persist.redis: PersistRedisStream
next
function next() returns record {| value record {} |}|Error?
close
function close() returns Error?
Clients
persist.redis: RedisClient
The client used by the generated persist clients to abstract and execute Redis database operations that are required to perform CRUD operations.
Constructor
Initializes the RedisClient
.
init (Client dbClient, RedisMetadata & readonly metadata, int maxAge)
- dbClient Client - The
redis:Client
, which is used to execute Redis database operations.
- metadata RedisMetadata & readonly - Metadata of the entity
- maxAge int -
runReadByKeyQuery
function runReadByKeyQuery(typedesc<record {}> rowType, map<anydata> typeMap, anydata key, string[] fields, string[] include, typedesc<record {}>[] typeDescriptions) returns record { anydata... }|Error
Performs a batch HGET
operation to get entity instances as a stream
Parameters
- rowType typedesc<record {}> - The type description of the entity to be retrieved
- typeMap map<anydata> - The data type map of the target type
- key anydata - Key for the record
- fields string[] (default []) - The fields to be retrieved
- include string[] (default []) - The associations to be retrieved
- typeDescriptions typedesc<record {}>[] (default []) - The type descriptions of the relations to be retrieved
Return Type
- record { anydata... }|Error - An
record {|anydata...;|}
containing the requested record or apersist:Error
if the operation fails
runReadQuery
function runReadQuery(typedesc<record {}> rowType, map<anydata> typeMap, string[] fields, string[] include) returns stream<record {}|error?>|Error
Performs a batch HGET
operation to get entity instances as a stream
Parameters
- rowType typedesc<record {}> - The type description of the entity to be retrieved
- typeMap map<anydata> - The data types of the record
- fields string[] (default []) - The fields to be retrieved
- include string[] (default []) - The associations to be retrieved
Return Type
runBatchInsertQuery
function runBatchInsertQuery(record {}[] insertRecords) returns string|Error
Performs a batch HMSET
operation to insert entity instances into a collection.
Parameters
- insertRecords record {}[] - The entity records to be inserted into the collection
Return Type
- string|Error - A
string
containing the information of the database operation execution or apersist:Error
if the operation fails
runDeleteQuery
function runDeleteQuery(anydata key) returns Error?
Performs redis DEL
operation to delete an entity record from the database.
Parameters
- key anydata - The ordered keys used to delete an entity record
Return Type
- Error? -
()
if the operation is performed successfully or apersist:Error
if the operation fails
runUpdateQuery
function runUpdateQuery(anydata key, record {} updateRecord) returns Error?
Performs redis HSET
operation to update an entity record from the database.
Parameters
- key anydata - The ordered keys used to update an entity record
- updateRecord record {} - The new record to be updated
Return Type
- Error? - An Error if the new record is missing a keyfield
getManyRelations
function getManyRelations(map<anydata> typeMap, record {} 'object, string[] fields, string[] include) returns Error?
Retrieves all the associations of a given object
Parameters
- typeMap map<anydata> - The data types of the record
- 'object record {} -
- fields string[] - The fields to be retrieved
- include string[] - The associations to be retrieved
Return Type
- Error? - A
persist:Error
if the operation fails
getKeyFields
function getKeyFields() returns string[]
Constants
Enums
persist.redis: CardinalityType
Represents the cardinality of the relationship
Only used by the generated persist clients and persist:RedisClient
.
Members
persist.redis: DataType
Represents the type of the field data.
Only used by the generated persist clients and persist:RedisClient
.
Members
Records
persist.redis: EntityFieldMetadata
Represents the metadata associated with a field from a related entity.
Fields
- relation RelationMetadata - The relational metadata associated with the field
persist.redis: RedisMetadata
Represents the metadata of an entity.
Fields
- entityName string - Name of the entity
- collectionName string - Collection name of the entity
- fieldMetadata map<FieldMetadata> - Metadata of all the fields of the entity
- keyFields string[] - Names of the identity fields
- refMetadata? map<RefMetadata> - Metadata of the fields that is being reffered
persist.redis: RefMetadata
Represents the metadata associated with relations
Only used by the generated persist clients and persist:RedisClient
.
Fields
- entity typedesc<record {}> - The name of the entity that is being joined
- fieldName string - The name of the field in the
entity
that is being joined
- refCollection string - The name of the Redis collection to be joined
- refMetaDataKey? string - The name of the Redis collection to be joined
- refFields string[] - The names of the fields of the refered collection
- joinFields string[] - The names of the join fields
- joinCollection? string - The name of the joining collection used for a many-to-many relation
- joiningRefFields? string[] - The names of the refered fields in the joining collection
- joiningJoinFields? string[] - The names of the join fields in the joining collection
- 'type CardinalityType - The type of the relation
persist.redis: RelationMetadata
Represents the metadata associated with a relation.
Only used by the generated persist clients and persist:RedisClient
.
Fields
- entityName string - The name of the entity represented in the relation
- refField string - The name of the refered field in the Redis document
- refFieldDataType DataType - The data type of the object field to which the refered field in Redis document is mapped
persist.redis: SimpleFieldMetadata
Represents the metadata associated with a simple field in the entity record.
Fields
- fieldName string - The name of the Redis document field to which the object field is mapped
- fieldDataType DataType - The data type of the object field to which the Redis document field mapped
Union types
persist.redis: FieldMetadata
FieldMetadata
Represents the metadata associated with a field of an entity.
Only used by the generated persist clients and persist:RedisClient
.
persist.redis: RedisFieldType
RedisFieldType
Generic type that can used to store any of the types supported by Redis
persist.redis: RedisTimeType
RedisTimeType
Generic type that can used to store any of time types supported by Redis
Import
import ballerinax/persist.redis;
Metadata
Released date: 12 days ago
Version: 0.3.0
License: Apache-2.0
Compatibility
Platform: java21
Ballerina version: 2201.11.0
GraalVM compatible: Yes
Pull count
Total: 5
Current verison: 0
Weekly downloads
Keywords
persist
redis
experimental
Contributors