Skip to main content

Variable: cosmos

const cosmos: object

Defined in: db.ts:143

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

Parameters

hash

IKeyValue

the key/values of the DB query (such as {uid: 'testUser@taf.com` })

Returns

IKeyValue

an object with each @key mapped to a value

buildQuery()

buildQuery: (hash) => string

Builds the SQL query portion of the DB request

Parameters

hash

IKeyValue

The key/values for the DB query (such as {uid: 'testUser@taf.com` })

Returns

string

a string of the SQL query

deleteOtpRecord()

deleteOtpRecord: (data) => Promise<boolean>

Deletes a record from Users

Parameters

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

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

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

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

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

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 these connections

Returns

Promise<void>

query()

query: (...args) => Promise<IQuery[]>

Queries RoomsAndUsers portion of presence DB.

Parameters

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

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

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

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

data

IKeyValue

The data of the record needing to be updated/saved

Returns

Promise<boolean>

A boolean indicating whether the value was saved/updated