Variable: cosmos
const cosmos: object;
Defined in: db.ts:173
Cosmos object with methods used to create, query, or delete records.
Type declaration
buildParams()
buildParams: (hash) => IKeyValue;
Builds the SQL parameters portion used to query DB
Builds the SQL parameters
Parameters
| Parameter | Type | Description |
|---|---|---|
hash | IKeyValue | An object to create the SQL parameters |
Returns
IKeyValue
An object with the key/value pairs in this format: @key: value
Param
the key/values of the DB query (such as {uid: 'testUser@taf.com` })
Returns
an object with each @key mapped to a value
buildQuery()
buildQuery: (hash) => string;
Builds the SQL query portion of the DB request
Builds a SQL Query based on the provided object
Parameters
| Parameter | Type | Description |
|---|---|---|
hash | IKeyValue | An object to create the SQL query |
Returns
string
A SQL query
Param
The key/values for the DB query (such as {uid: 'testUser@taf.com` })
Returns
a string of the SQL query
deleteOtpRecord()
deleteOtpRecord: (data) => Promise<boolean>;
Deletes a record from Users
Parameters
| Parameter | Type | Description |
|---|---|---|
data | IKeyValue | Data needed to find a specific record to delete (will delete based on the partitionKey) |
Returns
Promise<boolean>
A boolean indicating if a value was deleted successfully or not
deleteRecord()
deleteRecord: (data) => Promise<boolean>;
Deletes a record from RoomsAndUsers
Parameters
| Parameter | Type | Description |
|---|---|---|
data | IKeyValue | Data needed to find a specific record to delete (will delete based on the partitionKey) |
Returns
Promise<boolean>
A boolean indicating if a value was deleted successfully or not
dispose()
dispose: () => void;
Closes the DB connections
Returns
void
findAllOldUsers()
findAllOldUsers: () => Promise<RecordResponse[]>;
Finds old user records from the DB. These are records that either have version 1 or do not have a version in their user info.
Returns
Promise<RecordResponse[]>
A list of user records
findOtpRecord()
findOtpRecord: (values) => Promise<any>;
Finds an OTP record based on the provided values
Parameters
| Parameter | Type | Description |
|---|---|---|
values | IKeyValue | The hash values to find an OTP, such as an emailAddress |
Returns
Promise<any>
The single result or null if no record is found
findRecord()
findRecord: (id, uuid) => Promise<RecordResponse>;
Finds a record from RoomsAndUsers
Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | The id indicating what type of record to find, such as member, room, userRoom, or invite |
uuid | string | The UUID used to query the record |
Returns
Promise<RecordResponse>
The single result or null if no record is found
findRecords()
findRecords: (id) => Promise<RecordResponse[]>;
Finds multiple from RoomsAndUsers
Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | The id indicating what type of record to find, such as member, room, userRoom, otp, invite |
Returns
Promise<RecordResponse[]>
All the results from the id
findUserRecords()
findUserRecords: (id, room) => Promise<RecordResponse[]>;
Finds multiple user records based on the provided room UUID
Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | The record category, such as member |
room | string | The room UUID |
Returns
Promise<RecordResponse[]>
A list of users with the matching id and room uuid in their data.room
init()
init: () => Promise<void>;
Initializes the DB connections & methods needed to open/close. The following DB connections are initialized for these containers: "RoomsAndUsers", "Email", and "Sessions"
Returns
Promise<void>
query()
query: (...args) => Promise<IQuery[]>;
Queries RoomsAndUsers portion of presence DB.
Parameters
| Parameter | Type | Description |
|---|---|---|
...args | [string | SqlQuerySpec, IKeyValue] | The arguments used to query presence for DB results |
Returns
Promise<IQuery[]>
The query result
queryRecord()
queryRecord: (props) => Promise<RecordResponse>;
Queries RoomsAndUsers for a single record based on the provided properties.
Parameters
| Parameter | Type | Description |
|---|---|---|
props | IKeyValue | The properties to build a query for a record, such as { uuid: 0000-000-000-001} @returns The found record ornull` if no record was found |
Returns
Promise<RecordResponse>
queryRecords()
queryRecords: (props) => Promise<IQuery[]>;
Queries RoomsAndUsers for multiple records based on the provided properties.
Parameters
| Parameter | Type | Description |
|---|---|---|
props | IKeyValue | The properties to build a query for multiple records, such as { uuid: 0000-000-000-001` } |
Returns
Promise<IQuery[]>
A list of records that match the query. The list may be empty if no matching records were found.
saveOtpRecord()
saveOtpRecord: (data) => Promise<boolean>;
Saves a record in the otp db
Parameters
| Parameter | Type | Description |
|---|---|---|
data | IKeyValue | The data of the record needing to be updated/saved |
Returns
Promise<boolean>
A boolean indicating whether the value was saved/updated
saveRecord()
saveRecord: (data) => Promise<boolean>;
Saves a record in the RoomsAndUsers db
Parameters
| Parameter | Type | Description |
|---|---|---|
data | IKeyValue | The data of the record needing to be updated/saved |
Returns
Promise<boolean>
A boolean indicating whether the value was saved/updated