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
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
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
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
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
tableDrop()
tableDrop():
Promise<void>
Drop the table.
Returns
Promise<void>
Nothing.
tableEmpty()
tableEmpty():
Promise<void>
Empty the table.
Returns
Promise<void>
Nothing.
databaseExists()
databaseExists():
Promise<boolean>
Check if the database exists.
Returns
Promise<boolean>
True if the database exists, false otherwise.