Skip to content

@waylis/core


@waylis/core / ChatDatabase

Interface: ChatDatabase

Defined in: src/chat/chat.ts:18

Abstraction for chat persistence operations.

Extended by

Methods

addChat()

ts
addChat(chat: Chat): Promise<void>;

Defined in: src/chat/chat.ts:23

Add a new chat to the database.

Parameters

chat

Chat

Chat object to store.

Returns

Promise<void>


countChatsByCreatorID()

ts
countChatsByCreatorID(creatorID: string): Promise<number>;

Defined in: src/chat/chat.ts:44

Count how many chats were created by a user.

Parameters

creatorID

string

User identifier.

Returns

Promise<number>


deleteChatByID()

ts
deleteChatByID(id: string): Promise<null | Chat>;

Defined in: src/chat/chat.ts:59

Remove a chat by ID.

Parameters

id

string

Chat identifier.

Returns

Promise<null | Chat>

Deleted chat or null if not found.


editChatByID()

ts
editChatByID(id: string, updated: Partial<Chat>): Promise<null | Chat>;

Defined in: src/chat/chat.ts:52

Update a chat by ID.

Parameters

id

string

Chat identifier.

updated

Partial<Chat>

Partial fields to update.

Returns

Promise<null | Chat>

Updated chat or null if not found.


getChatByID()

ts
getChatByID(id: string): Promise<null | Chat>;

Defined in: src/chat/chat.ts:30

Retrieve a chat by its ID.

Parameters

id

string

Chat identifier.

Returns

Promise<null | Chat>

Chat if found, otherwise null.


getChatsByCreatorID()

ts
getChatsByCreatorID(
   creatorID: string, 
   offset: number, 
limit: number): Promise<Chat[]>;

Defined in: src/chat/chat.ts:38

Retrieve chats created by a specific user.

Parameters

creatorID

string

User identifier.

offset

number

Skip this many results.

limit

number

Maximum number of results.

Returns

Promise<Chat[]>

Released under the MIT License.