Class: MySqlEntityStorageConnector<T>
Class for performing entity storage operations using MySql.
Type Parameters
T
T = unknown
Implements
IEntityStorageConnector<T>
Constructors
Constructor
new MySqlEntityStorageConnector<
T>(options):MySqlEntityStorageConnector<T>
Create a new instance of MySqlEntityStorageConnector.
Parameters
options
IMySqlEntityStorageConnectorConstructorOptions
The options for the connector.
Returns
MySqlEntityStorageConnector<T>
Properties
CLASS_NAME
readonlystaticCLASS_NAME:string
Runtime name for the class.
Methods
className()
className():
string
Returns the class name of the component.
Returns
string
The class name of the component.
Implementation of
IEntityStorageConnector.className
health()
health():
Promise<IHealth[]>
Get the health of the component.
Returns
Promise<IHealth[]>
The health of the component.
Implementation of
IEntityStorageConnector.health
getSchema()
getSchema():
IEntitySchema
Get the schema for the entities.
Returns
IEntitySchema
The schema for the entities.
Implementation of
IEntityStorageConnector.getSchema
bootstrap()
bootstrap(
nodeLoggingComponentType?):Promise<boolean>
Initialize the MySql environment.
Parameters
nodeLoggingComponentType?
string
Optional type of the logging component.
Returns
Promise<boolean>
A promise that resolves to a boolean indicating success.
Implementation of
IEntityStorageConnector.bootstrap
stop()
stop(
nodeLoggingComponentType?):Promise<void>
The component needs to be stopped when the node is closed.
Parameters
nodeLoggingComponentType?
string
The node logging component type.
Returns
Promise<void>
Nothing.
Implementation of
IEntityStorageConnector.stop
get()
get(
id,secondaryIndex?,conditions?):Promise<T|undefined>
Get an entity from MySql.
Parameters
id
string
The id of the entity to get, or the index value if secondaryIndex is set.
secondaryIndex?
keyof T
Get the item using a secondary index.
conditions?
object[]
The optional conditions to match for the entities.
Returns
Promise<T | undefined>
The object if it can be found or undefined.
Implementation of
IEntityStorageConnector.get
set()
set(
entity,conditions?):Promise<void>
Set an entity.
Parameters
entity
T
The entity to set.
conditions?
object[]
The optional conditions to match for the entities.
Returns
Promise<void>
The id of the entity.
Implementation of
IEntityStorageConnector.set
setBatch()
setBatch(
entities):Promise<void>
Set multiple entities in a batch.
Parameters
entities
T[]
The entities to set.
Returns
Promise<void>
Nothing.
Implementation of
IEntityStorageConnector.setBatch
empty()
empty():
Promise<void>
Empty the entity storage.
Returns
Promise<void>
Nothing.
Implementation of
IEntityStorageConnector.empty
remove()
remove(
id,conditions?):Promise<void>
Remove the entity.
Parameters
id
string
The id of the entity to remove.
conditions?
object[]
The optional conditions to match for the entities.
Returns
Promise<void>
Nothing.
Implementation of
IEntityStorageConnector.remove
teardown()
teardown(
nodeLoggingComponentType?):Promise<boolean>
Teardown the entity storage by dropping the table.
Parameters
nodeLoggingComponentType?
string
The node logging component type.
Returns
Promise<boolean>
True if the teardown process was successful.
Implementation of
IEntityStorageConnector.teardown
removeBatch()
removeBatch(
ids):Promise<void>
Remove multiple entities by their primary key IDs.
Parameters
ids
string[]
The ids of the entities to remove.
Returns
Promise<void>
Nothing.
Implementation of
IEntityStorageConnector.removeBatch
query()
query(
conditions?,sortProperties?,properties?,cursor?,limit?):Promise<{entities:Partial<T>[];cursor?:string; }>
Find all the entities which match the conditions.
Parameters
conditions?
EntityCondition<T>
The conditions to match for the entities.
sortProperties?
object[]
The optional sort order.
properties?
keyof T[]
The optional properties to return, defaults to all.
cursor?
string
The cursor to request the next chunk of entities.
limit?
number
The suggested number of entities to return in each chunk, in some scenarios can return a different amount.
Returns
Promise<{ entities: Partial<T>[]; cursor?: string; }>
All the entities for the storage matching the conditions, and a cursor which can be used to request more entities.
Implementation of
IEntityStorageConnector.query
count()
count():
Promise<number>
Count all the entities which match the conditions.
Returns
Promise<number>
The total count of entities in the storage.
Implementation of
IEntityStorageConnector.count
databaseExists()
databaseExists():
Promise<boolean>
Check if the database exists.
Returns
Promise<boolean>
True if the database exists, false otherwise.