Skip to main content

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

ParameterTypeDescription
hashIKeyValueAn 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

ParameterTypeDescription
hashIKeyValueAn 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

ParameterTypeDescription
dataIKeyValueData 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

ParameterTypeDescription
dataIKeyValueData 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

ParameterTypeDescription
valuesIKeyValueThe 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

ParameterTypeDescription
idstringThe id indicating what type of record to find, such as member, room, userRoom, or invite
uuidstringThe 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

ParameterTypeDescription
idstringThe 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

ParameterTypeDescription
idstringThe record category, such as member
roomstringThe 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

ParameterTypeDescription
...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

ParameterTypeDescription
propsIKeyValueThe 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

ParameterTypeDescription
propsIKeyValueThe 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

ParameterTypeDescription
dataIKeyValueThe 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

ParameterTypeDescription
dataIKeyValueThe data of the record needing to be updated/saved

Returns

Promise<boolean>

A boolean indicating whether the value was saved/updated