Skip to main content

Class: SupabaseDatabaseAdapter

An abstract class representing a database adapter for managing various entities like accounts, memories, actors, goals, and rooms.

Hierarchy

Constructors

constructor

new SupabaseDatabaseAdapter(supabaseUrl, supabaseKey): SupabaseDatabaseAdapter

Parameters

NameType
supabaseUrlstring
supabaseKeystring

Returns

SupabaseDatabaseAdapter

Overrides

DatabaseAdapter.constructor

Properties

supabase

supabase: default<any, "public", any>

Methods

addParticipant

addParticipant(user_id, room_id): Promise<boolean>

Adds a user as a participant to a specific room.

Parameters

NameTypeDescription
user_id`${string}-${string}-${string}-${string}-${string}`The UUID of the user to add as a participant.
room_id`${string}-${string}-${string}-${string}-${string}`The UUID of the room to which the user will be added.

Returns

Promise<boolean>

A Promise that resolves to a boolean indicating success or failure.

Overrides

DatabaseAdapter.addParticipant


countMemories

countMemories(room_id, unique?, tableName): Promise<number>

Counts the number of memories in a specific room.

Parameters

NameTypeDefault valueDescription
room_id`${string}-${string}-${string}-${string}-${string}`undefinedThe UUID of the room for which to count memories.
uniquebooleantrueSpecifies whether to count only unique memories.
tableNamestringundefinedOptional table name to count memories from.

Returns

Promise<number>

A Promise that resolves to the number of memories.

Overrides

DatabaseAdapter.countMemories


createAccount

createAccount(account): Promise<boolean>

Creates a new account in the database.

Parameters

NameTypeDescription
accountAccountThe account object to create.

Returns

Promise<boolean>

A Promise that resolves when the account creation is complete.

Overrides

DatabaseAdapter.createAccount


createGoal

createGoal(goal): Promise<void>

Creates a new goal in the database.

Parameters

NameTypeDescription
goalGoalThe goal object to create.

Returns

Promise<void>

A Promise that resolves when the goal has been created.

Overrides

DatabaseAdapter.createGoal


createMemory

createMemory(memory, tableName, unique?): Promise<void>

Creates a new memory in the database.

Parameters

NameTypeDefault valueDescription
memoryMemoryundefinedThe memory object to create.
tableNamestringundefinedThe table where the memory should be stored.
uniquebooleanfalseIndicates if the memory should be unique.

Returns

Promise<void>

A Promise that resolves when the memory has been created.

Overrides

DatabaseAdapter.createMemory


createRelationship

createRelationship(params): Promise<boolean>

Creates a new relationship between two users.

Parameters

NameTypeDescription
paramsObjectAn object containing the UUIDs of the two users (userA and userB).
params.userA`${string}-${string}-${string}-${string}-${string}`-
params.userB`${string}-${string}-${string}-${string}-${string}`-

Returns

Promise<boolean>

A Promise that resolves to a boolean indicating success or failure of the creation.

Overrides

DatabaseAdapter.createRelationship


createRoom

createRoom(room_id?): Promise<`${string}-${string}-${string}-${string}-${string}`>

Creates a new room with an optional specified ID.

Parameters

NameTypeDescription
room_id?`${string}-${string}-${string}-${string}-${string}`Optional UUID to assign to the new room.

Returns

Promise<`${string}-${string}-${string}-${string}-${string}`>

A Promise that resolves to the UUID of the created room.

Overrides

DatabaseAdapter.createRoom


getAccountById

getAccountById(user_id): Promise<null | Account>

Retrieves an account by its ID.

Parameters

NameTypeDescription
user_id`${string}-${string}-${string}-${string}-${string}`The UUID of the user account to retrieve.

Returns

Promise<null | Account>

A Promise that resolves to the Account object or null if not found.

Overrides

DatabaseAdapter.getAccountById


getActorDetails

getActorDetails(params): Promise<Actor[]>

Retrieves details of actors in a given room.

Parameters

NameTypeDescription
paramsObjectAn object containing the room_id to search for actors.
params.room_id`${string}-${string}-${string}-${string}-${string}`-

Returns

Promise<Actor[]>

A Promise that resolves to an array of Actor objects.

Overrides

DatabaseAdapter.getActorDetails


getCachedEmbeddings

getCachedEmbeddings(opts): Promise<{ embedding: number[] ; levenshtein_score: number }[]>

Retrieves cached embeddings based on the specified query parameters.

Parameters

NameTypeDescription
optsObjectAn object containing parameters for the embedding retrieval.
opts.query_field_namestring-
opts.query_field_sub_namestring-
opts.query_inputstring-
opts.query_match_countnumber-
opts.query_table_namestring-
opts.query_thresholdnumber-

Returns

Promise<{ embedding: number[] ; levenshtein_score: number }[]>

A Promise that resolves to an array of objects containing embeddings and levenshtein scores.

Overrides

DatabaseAdapter.getCachedEmbeddings


getGoals

getGoals(params): Promise<Goal[]>

Retrieves goals based on specified parameters.

Parameters

NameTypeDescription
paramsObjectAn object containing parameters for goal retrieval.
params.count?number-
params.onlyInProgress?boolean-
params.room_id`${string}-${string}-${string}-${string}-${string}`-
params.user_id?null | `${string}-${string}-${string}-${string}-${string}`-

Returns

Promise<Goal[]>

A Promise that resolves to an array of Goal objects.

Overrides

DatabaseAdapter.getGoals


getMemories

getMemories(params): Promise<Memory[]>

Retrieves memories based on the specified parameters.

Parameters

NameTypeDescription
paramsObjectAn object containing parameters for the memory retrieval.
params.count?number-
params.room_id`${string}-${string}-${string}-${string}-${string}`-
params.tableNamestring-
params.unique?boolean-

Returns

Promise<Memory[]>

A Promise that resolves to an array of Memory objects.

Overrides

DatabaseAdapter.getMemories


getParticipantsForAccount

getParticipantsForAccount(user_id): Promise<Participant[]>

Retrieves participants associated with a specific account.

Parameters

NameTypeDescription
user_id`${string}-${string}-${string}-${string}-${string}`The UUID of the account.

Returns

Promise<Participant[]>

A Promise that resolves to an array of Participant objects.

Overrides

DatabaseAdapter.getParticipantsForAccount


getParticipantsForRoom

getParticipantsForRoom(room_id): Promise<`${string}-${string}-${string}-${string}-${string}`[]>

Retrieves participants for a specific room.

Parameters

NameTypeDescription
room_id`${string}-${string}-${string}-${string}-${string}`The UUID of the room for which to retrieve participants.

Returns

Promise<`${string}-${string}-${string}-${string}-${string}`[]>

A Promise that resolves to an array of UUIDs representing the participants.

Overrides

DatabaseAdapter.getParticipantsForRoom


getRelationship

getRelationship(params): Promise<null | Relationship>

Retrieves a relationship between two users if it exists.

Parameters

NameTypeDescription
paramsObjectAn object containing the UUIDs of the two users (userA and userB).
params.userA`${string}-${string}-${string}-${string}-${string}`-
params.userB`${string}-${string}-${string}-${string}-${string}`-

Returns

Promise<null | Relationship>

A Promise that resolves to the Relationship object or null if not found.

Overrides

DatabaseAdapter.getRelationship


getRelationships

getRelationships(params): Promise<Relationship[]>

Retrieves all relationships for a specific user.

Parameters

NameTypeDescription
paramsObjectAn object containing the UUID of the user.
params.user_id`${string}-${string}-${string}-${string}-${string}`-

Returns

Promise<Relationship[]>

A Promise that resolves to an array of Relationship objects.

Overrides

DatabaseAdapter.getRelationships


getRoom

getRoom(room_id): Promise<null | `${string}-${string}-${string}-${string}-${string}`>

Retrieves the room ID for a given room, if it exists.

Parameters

NameTypeDescription
room_id`${string}-${string}-${string}-${string}-${string}`The UUID of the room to retrieve.

Returns

Promise<null | `${string}-${string}-${string}-${string}-${string}`>

A Promise that resolves to the room ID or null if not found.

Overrides

DatabaseAdapter.getRoom


getRoomsForParticipant

getRoomsForParticipant(user_id): Promise<`${string}-${string}-${string}-${string}-${string}`[]>

Retrieves room IDs for which a specific user is a participant.

Parameters

NameTypeDescription
user_id`${string}-${string}-${string}-${string}-${string}`The UUID of the user.

Returns

Promise<`${string}-${string}-${string}-${string}-${string}`[]>

A Promise that resolves to an array of room IDs.

Overrides

DatabaseAdapter.getRoomsForParticipant


getRoomsForParticipants

getRoomsForParticipants(userIds): Promise<`${string}-${string}-${string}-${string}-${string}`[]>

Retrieves room IDs for which specific users are participants.

Parameters

NameTypeDescription
userIds`${string}-${string}-${string}-${string}-${string}`[]An array of UUIDs of the users.

Returns

Promise<`${string}-${string}-${string}-${string}-${string}`[]>

A Promise that resolves to an array of room IDs.

Overrides

DatabaseAdapter.getRoomsForParticipants


log

log(params): Promise<void>

Logs an event or action with the specified details.

Parameters

NameTypeDescription
paramsObjectAn object containing parameters for the log entry.
params.bodyObject-
params.room_id`${string}-${string}-${string}-${string}-${string}`-
params.typestring-
params.user_id`${string}-${string}-${string}-${string}-${string}`-

Returns

Promise<void>

A Promise that resolves when the log entry has been saved.

Overrides

DatabaseAdapter.log


removeAllGoals

removeAllGoals(room_id): Promise<void>

Removes all goals associated with a specific room.

Parameters

NameTypeDescription
room_id`${string}-${string}-${string}-${string}-${string}`The UUID of the room whose goals should be removed.

Returns

Promise<void>

A Promise that resolves when all goals have been removed.

Overrides

DatabaseAdapter.removeAllGoals


removeAllMemories

removeAllMemories(room_id, tableName): Promise<void>

Removes all memories associated with a specific room.

Parameters

NameTypeDescription
room_id`${string}-${string}-${string}-${string}-${string}`The UUID of the room whose memories should be removed.
tableNamestringThe table from which the memories should be removed.

Returns

Promise<void>

A Promise that resolves when all memories have been removed.

Overrides

DatabaseAdapter.removeAllMemories


removeGoal

removeGoal(goalId): Promise<void>

Removes a specific goal from the database.

Parameters

NameTypeDescription
goalId`${string}-${string}-${string}-${string}-${string}`The UUID of the goal to remove.

Returns

Promise<void>

A Promise that resolves when the goal has been removed.

Overrides

DatabaseAdapter.removeGoal


removeMemory

removeMemory(memoryId): Promise<void>

Removes a specific memory from the database.

Parameters

NameTypeDescription
memoryId`${string}-${string}-${string}-${string}-${string}`The UUID of the memory to remove.

Returns

Promise<void>

A Promise that resolves when the memory has been removed.

Overrides

DatabaseAdapter.removeMemory


removeParticipant

removeParticipant(user_id, room_id): Promise<boolean>

Removes a user as a participant from a specific room.

Parameters

NameTypeDescription
user_id`${string}-${string}-${string}-${string}-${string}`The UUID of the user to remove as a participant.
room_id`${string}-${string}-${string}-${string}-${string}`The UUID of the room from which the user will be removed.

Returns

Promise<boolean>

A Promise that resolves to a boolean indicating success or failure.

Overrides

DatabaseAdapter.removeParticipant


removeRoom

removeRoom(room_id): Promise<void>

Removes a specific room from the database.

Parameters

NameTypeDescription
room_id`${string}-${string}-${string}-${string}-${string}`The UUID of the room to remove.

Returns

Promise<void>

A Promise that resolves when the room has been removed.

Overrides

DatabaseAdapter.removeRoom


searchMemories

searchMemories(params): Promise<Memory[]>

Searches for memories based on embeddings and other specified parameters.

Parameters

NameTypeDescription
paramsObjectAn object containing parameters for the memory search.
params.embeddingnumber[]-
params.match_countnumber-
params.match_thresholdnumber-
params.room_id`${string}-${string}-${string}-${string}-${string}`-
params.tableNamestring-
params.uniqueboolean-

Returns

Promise<Memory[]>

A Promise that resolves to an array of Memory objects.

Overrides

DatabaseAdapter.searchMemories


searchMemoriesByEmbedding

searchMemoriesByEmbedding(embedding, params): Promise<Memory[]>

Searches for memories by embedding and other specified parameters.

Parameters

NameTypeDescription
embeddingnumber[]The embedding vector to search with.
paramsObjectAdditional parameters for the search.
params.count?number-
params.match_threshold?number-
params.room_id?`${string}-${string}-${string}-${string}-${string}`-
params.tableNamestring-
params.unique?boolean-

Returns

Promise<Memory[]>

A Promise that resolves to an array of Memory objects.

Overrides

DatabaseAdapter.searchMemoriesByEmbedding


updateGoal

updateGoal(goal): Promise<void>

Updates a specific goal in the database.

Parameters

NameTypeDescription
goalGoalThe goal object with updated properties.

Returns

Promise<void>

A Promise that resolves when the goal has been updated.

Overrides

DatabaseAdapter.updateGoal


updateGoalStatus

updateGoalStatus(params): Promise<void>

Updates the status of a specific goal.

Parameters

NameTypeDescription
paramsObjectAn object containing the goalId and the new status.
params.goalId`${string}-${string}-${string}-${string}-${string}`-
params.statusGoalStatus-

Returns

Promise<void>

A Promise that resolves when the goal status has been updated.

Overrides

DatabaseAdapter.updateGoalStatus