@ai16z/eliza v0.1.4-alpha.3 / DatabaseAdapter
An abstract class representing a database adapter for managing various entities like accounts, memories, actors, goals, and rooms.
• DB = any
new DatabaseAdapter<
DB>():DatabaseAdapter<DB>
DatabaseAdapter<DB>
db:
DB
The database instance.
packages/core/src/database.ts:21
abstractinit():Promise<void>
Optional initialization method for the database adapter.
Promise<void>
A Promise that resolves when initialization is complete.
packages/core/src/database.ts:27
abstractclose():Promise<void>
Optional close method for the database adapter.
Promise<void>
A Promise that resolves when closing is complete.
packages/core/src/database.ts:33
abstractgetAccountById(userId):Promise<Account>
Retrieves an account by its ID.
• userId: `${string}-${string}-${string}-${string}-${string}`
The UUID of the user account to retrieve.
Promise<Account>
A Promise that resolves to the Account object or null if not found.
IDatabaseAdapter.getAccountById
packages/core/src/database.ts:40
abstractcreateAccount(account):Promise<boolean>
Creates a new account in the database.
• account: Account
The account object to create.
Promise<boolean>
A Promise that resolves when the account creation is complete.
IDatabaseAdapter.createAccount
packages/core/src/database.ts:47
abstractgetMemories(params):Promise<Memory[]>
Retrieves memories based on the specified parameters.
• params
An object containing parameters for the memory retrieval.
• params.agentId: `${string}-${string}-${string}-${string}-${string}`
• params.roomId: `${string}-${string}-${string}-${string}-${string}`
• params.count?: number
• params.unique?: boolean
• params.tableName: string
Promise<Memory[]>
A Promise that resolves to an array of Memory objects.
packages/core/src/database.ts:54
abstractgetMemoriesByRoomIds(params):Promise<Memory[]>
• params
• params.agentId: `${string}-${string}-${string}-${string}-${string}`
• params.roomIds: `${string}-${string}-${string}-${string}-${string}`[]
• params.tableName: string
Promise<Memory[]>
IDatabaseAdapter.getMemoriesByRoomIds
packages/core/src/database.ts:62
abstractgetMemoryById(id):Promise<Memory>
• id: `${string}-${string}-${string}-${string}-${string}`
Promise<Memory>
IDatabaseAdapter.getMemoryById
packages/core/src/database.ts:68
abstractgetCachedEmbeddings(params):Promise<object[]>
Retrieves cached embeddings based on the specified query parameters.
• params
An object containing parameters for the embedding retrieval.
• params.query_table_name: string
• params.query_threshold: number
• params.query_input: string
• params.query_field_name: string
• params.query_field_sub_name: string
• params.query_match_count: number
Promise<object[]>
A Promise that resolves to an array of objects containing embeddings and levenshtein scores.
IDatabaseAdapter.getCachedEmbeddings
packages/core/src/database.ts:75
abstractlog(params):Promise<void>
Logs an event or action with the specified details.
• params
An object containing parameters for the log entry.
• params.body
• params.userId: `${string}-${string}-${string}-${string}-${string}`
• params.roomId: `${string}-${string}-${string}-${string}-${string}`
• params.type: string
Promise<void>
A Promise that resolves when the log entry has been saved.
packages/core/src/database.ts:101
abstractgetActorDetails(params):Promise<Actor[]>
Retrieves details of actors in a given room.
• params
An object containing the roomId to search for actors.
• params.roomId: `${string}-${string}-${string}-${string}-${string}`
Promise<Actor[]>
A Promise that resolves to an array of Actor objects.
IDatabaseAdapter.getActorDetails
packages/core/src/database.ts:113
abstractsearchMemories(params):Promise<Memory[]>
Searches for memories based on embeddings and other specified parameters.
• params
An object containing parameters for the memory search.
• params.tableName: string
• params.agentId: `${string}-${string}-${string}-${string}-${string}`
• params.roomId: `${string}-${string}-${string}-${string}-${string}`
• params.embedding: number[]
• params.match_threshold: number
• params.match_count: number
• params.unique: boolean
Promise<Memory[]>
A Promise that resolves to an array of Memory objects.
IDatabaseAdapter.searchMemories
packages/core/src/database.ts:120
abstractupdateGoalStatus(params):Promise<void>
Updates the status of a specific goal.
• params
An object containing the goalId and the new status.
• params.goalId: `${string}-${string}-${string}-${string}-${string}`
• params.status: GoalStatus
Promise<void>
A Promise that resolves when the goal status has been updated.
IDatabaseAdapter.updateGoalStatus
packages/core/src/database.ts:135
abstractsearchMemoriesByEmbedding(embedding,params):Promise<Memory[]>
Searches for memories by embedding and other specified parameters.
• embedding: number[]
The embedding vector to search with.
• params
Additional parameters for the search.
• params.match_threshold?: number
• params.count?: number
• params.roomId?: `${string}-${string}-${string}-${string}-${string}`
• params.agentId?: `${string}-${string}-${string}-${string}-${string}`
• params.unique?: boolean
• params.tableName: string
Promise<Memory[]>
A Promise that resolves to an array of Memory objects.
IDatabaseAdapter.searchMemoriesByEmbedding
packages/core/src/database.ts:146
abstractcreateMemory(memory,tableName,unique?):Promise<void>
Creates a new memory in the database.
• memory: Memory
The memory object to create.
• tableName: string
The table where the memory should be stored.
• unique?: boolean
Indicates if the memory should be unique.
Promise<void>
A Promise that resolves when the memory has been created.
packages/core/src/database.ts:165
abstractremoveMemory(memoryId,tableName):Promise<void>
Removes a specific memory from the database.
• memoryId: `${string}-${string}-${string}-${string}-${string}`
The UUID of the memory to remove.
• tableName: string
The table from which the memory should be removed.
Promise<void>
A Promise that resolves when the memory has been removed.
packages/core/src/database.ts:177
abstractremoveAllMemories(roomId,tableName):Promise<void>
Removes all memories associated with a specific room.
• roomId: `${string}-${string}-${string}-${string}-${string}`
The UUID of the room whose memories should be removed.
• tableName: string
The table from which the memories should be removed.
Promise<void>
A Promise that resolves when all memories have been removed.
IDatabaseAdapter.removeAllMemories
packages/core/src/database.ts:185
abstractcountMemories(roomId,unique?,tableName?):Promise<number>
Counts the number of memories in a specific room.
• roomId: `${string}-${string}-${string}-${string}-${string}`
The UUID of the room for which to count memories.
• unique?: boolean
Specifies whether to count only unique memories.
• tableName?: string
Optional table name to count memories from.
Promise<number>
A Promise that resolves to the number of memories.
IDatabaseAdapter.countMemories
packages/core/src/database.ts:194
abstractgetGoals(params):Promise<Goal[]>
Retrieves goals based on specified parameters.
• params
An object containing parameters for goal retrieval.
• params.agentId: `${string}-${string}-${string}-${string}-${string}`
• params.roomId: `${string}-${string}-${string}-${string}-${string}`
• params.userId?: `${string}-${string}-${string}-${string}-${string}`
• params.onlyInProgress?: boolean
• params.count?: number
Promise<Goal[]>
A Promise that resolves to an array of Goal objects.
packages/core/src/database.ts:205
abstractupdateGoal(goal):Promise<void>
Updates a specific goal in the database.
• goal: Goal
The goal object with updated properties.
Promise<void>
A Promise that resolves when the goal has been updated.
packages/core/src/database.ts:218
abstractcreateGoal(goal):Promise<void>
Creates a new goal in the database.
• goal: Goal
The goal object to create.
Promise<void>
A Promise that resolves when the goal has been created.
packages/core/src/database.ts:225
abstractremoveGoal(goalId):Promise<void>
Removes a specific goal from the database.
• goalId: `${string}-${string}-${string}-${string}-${string}`
The UUID of the goal to remove.
Promise<void>
A Promise that resolves when the goal has been removed.
packages/core/src/database.ts:232
abstractremoveAllGoals(roomId):Promise<void>
Removes all goals associated with a specific room.
• roomId: `${string}-${string}-${string}-${string}-${string}`
The UUID of the room whose goals should be removed.
Promise<void>
A Promise that resolves when all goals have been removed.
IDatabaseAdapter.removeAllGoals
packages/core/src/database.ts:239
abstractgetRoom(roomId):Promise<`${string}-${string}-${string}-${string}-${string}`>
Retrieves the room ID for a given room, if it exists.
• roomId: `${string}-${string}-${string}-${string}-${string}`
The UUID of the room to retrieve.
Promise<`${string}-${string}-${string}-${string}-${string}`>
A Promise that resolves to the room ID or null if not found.
packages/core/src/database.ts:246
abstractcreateRoom(roomId?):Promise<`${string}-${string}-${string}-${string}-${string}`>
Creates a new room with an optional specified ID.
• roomId?: `${string}-${string}-${string}-${string}-${string}`
Optional UUID to assign to the new room.
Promise<`${string}-${string}-${string}-${string}-${string}`>
A Promise that resolves to the UUID of the created room.
packages/core/src/database.ts:253
abstractremoveRoom(roomId):Promise<void>
Removes a specific room from the database.
• roomId: `${string}-${string}-${string}-${string}-${string}`
The UUID of the room to remove.
Promise<void>
A Promise that resolves when the room has been removed.
packages/core/src/database.ts:260
abstractgetRoomsForParticipant(userId):Promise<`${string}-${string}-${string}-${string}-${string}`[]>
Retrieves room IDs for which a specific user is a participant.
• userId: `${string}-${string}-${string}-${string}-${string}`
The UUID of the user.
Promise<`${string}-${string}-${string}-${string}-${string}`[]>
A Promise that resolves to an array of room IDs.
IDatabaseAdapter.getRoomsForParticipant
packages/core/src/database.ts:267
abstractgetRoomsForParticipants(userIds):Promise<`${string}-${string}-${string}-${string}-${string}`[]>
Retrieves room IDs for which specific users are participants.
• userIds: `${string}-${string}-${string}-${string}-${string}`[]
An array of UUIDs of the users.
Promise<`${string}-${string}-${string}-${string}-${string}`[]>
A Promise that resolves to an array of room IDs.
IDatabaseAdapter.getRoomsForParticipants
packages/core/src/database.ts:274
abstractaddParticipant(userId,roomId):Promise<boolean>
Adds a user as a participant to a specific room.
• userId: `${string}-${string}-${string}-${string}-${string}`
The UUID of the user to add as a participant.
• roomId: `${string}-${string}-${string}-${string}-${string}`
The UUID of the room to which the user will be added.
Promise<boolean>
A Promise that resolves to a boolean indicating success or failure.
IDatabaseAdapter.addParticipant
packages/core/src/database.ts:282
abstractremoveParticipant(userId,roomId):Promise<boolean>
Removes a user as a participant from a specific room.
• userId: `${string}-${string}-${string}-${string}-${string}`
The UUID of the user to remove as a participant.
• roomId: `${string}-${string}-${string}-${string}-${string}`
The UUID of the room from which the user will be removed.
Promise<boolean>
A Promise that resolves to a boolean indicating success or failure.
IDatabaseAdapter.removeParticipant
packages/core/src/database.ts:290
abstractgetParticipantsForAccount(userId):Promise<Participant[]>
Retrieves participants associated with a specific account.
• userId: `${string}-${string}-${string}-${string}-${string}`
The UUID of the account.
Promise<Participant[]>
A Promise that resolves to an array of Participant objects.
IDatabaseAdapter.getParticipantsForAccount
packages/core/src/database.ts:297
abstractgetParticipantsForAccount(userId):Promise<Participant[]>
Retrieves participants associated with a specific account.
• userId: `${string}-${string}-${string}-${string}-${string}`
The UUID of the account.
Promise<Participant[]>
A Promise that resolves to an array of Participant objects.
IDatabaseAdapter.getParticipantsForAccount
packages/core/src/database.ts:304
abstractgetParticipantsForRoom(roomId):Promise<`${string}-${string}-${string}-${string}-${string}`[]>
Retrieves participants for a specific room.
• roomId: `${string}-${string}-${string}-${string}-${string}`
The UUID of the room for which to retrieve participants.
Promise<`${string}-${string}-${string}-${string}-${string}`[]>
A Promise that resolves to an array of UUIDs representing the participants.
IDatabaseAdapter.getParticipantsForRoom
packages/core/src/database.ts:311
abstractgetParticipantUserState(roomId,userId):Promise<"FOLLOWED"|"MUTED">
• roomId: `${string}-${string}-${string}-${string}-${string}`
• userId: `${string}-${string}-${string}-${string}-${string}`
Promise<"FOLLOWED" | "MUTED">
IDatabaseAdapter.getParticipantUserState
packages/core/src/database.ts:313
abstractsetParticipantUserState(roomId,userId,state):Promise<void>
• roomId: `${string}-${string}-${string}-${string}-${string}`
• userId: `${string}-${string}-${string}-${string}-${string}`
• state: "FOLLOWED" | "MUTED"
Promise<void>
IDatabaseAdapter.setParticipantUserState
packages/core/src/database.ts:317
abstractcreateRelationship(params):Promise<boolean>
Creates a new relationship between two users.
• params
An 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}`
Promise<boolean>
A Promise that resolves to a boolean indicating success or failure of the creation.
IDatabaseAdapter.createRelationship
packages/core/src/database.ts:328
abstractgetRelationship(params):Promise<Relationship>
Retrieves a relationship between two users if it exists.
• params
An 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}`
Promise<Relationship>
A Promise that resolves to the Relationship object or null if not found.
IDatabaseAdapter.getRelationship
packages/core/src/database.ts:338
abstractgetRelationships(params):Promise<Relationship[]>
Retrieves all relationships for a specific user.
• params
An object containing the UUID of the user.
• params.userId: `${string}-${string}-${string}-${string}-${string}`
Promise<Relationship[]>
A Promise that resolves to an array of Relationship objects.