pub struct Database { /* private fields */ }
Implementations§
source§impl Database
impl Database
pub async fn create_access_token( &self, user_id: UserId, access_token_hash: &str, max_access_token_count: usize ) -> Result<AccessTokenId>
pub async fn get_access_token( &self, access_token_id: AccessTokenId ) -> Result<Model>
source§impl Database
impl Database
pub async fn join_channel_buffer( &self, channel_id: ChannelId, user_id: UserId, connection: ConnectionId ) -> Result<JoinChannelBufferResponse>
pub async fn rejoin_channel_buffers( &self, buffers: &[ChannelBufferVersion], user_id: UserId, connection_id: ConnectionId ) -> Result<Vec<RejoinedChannelBuffer>>
pub async fn clear_stale_channel_buffer_collaborators( &self, channel_id: ChannelId, server_id: ServerId ) -> Result<RefreshedChannelBuffer>
pub async fn leave_channel_buffer( &self, channel_id: ChannelId, connection: ConnectionId ) -> Result<LeftChannelBuffer>
pub async fn channel_buffer_connection_lost( &self, connection: ConnectionId, tx: &DatabaseTransaction ) -> Result<()>
pub async fn leave_channel_buffers( &self, connection: ConnectionId ) -> Result<Vec<LeftChannelBuffer>>
pub async fn leave_channel_buffer_internal( &self, channel_id: ChannelId, connection: ConnectionId, tx: &DatabaseTransaction ) -> Result<LeftChannelBuffer>
pub async fn get_channel_buffer_collaborators( &self, channel_id: ChannelId ) -> Result<Vec<UserId>>
pub async fn update_channel_buffer( &self, channel_id: ChannelId, user: UserId, operations: &[Operation] ) -> Result<(Vec<ConnectionId>, Vec<UserId>, i32, Vec<VectorClockEntry>)>
pub async fn get_channel_buffer( &self, channel_id: ChannelId, tx: &DatabaseTransaction ) -> Result<Model>
pub async fn observe_buffer_version( &self, buffer_id: BufferId, user_id: UserId, epoch: i32, version: &[VectorClockEntry] ) -> Result<()>
pub async fn unseen_channel_buffer_changes( &self, user_id: UserId, channel_ids: &[ChannelId], tx: &DatabaseTransaction ) -> Result<Vec<UnseenChannelBufferChange>>
pub async fn get_latest_operations_for_buffers( &self, buffer_ids: impl IntoIterator<Item = BufferId>, tx: &DatabaseTransaction ) -> Result<Vec<Model>>
source§impl Database
impl Database
pub async fn create_channel( &self, name: &str, parent_channel_id: Option<ChannelId>, admin_id: UserId ) -> Result<CreateChannelResult>
pub async fn join_channel( &self, channel_id: ChannelId, user_id: UserId, connection: ConnectionId, environment: &str ) -> Result<(JoinRoom, Option<MembershipUpdated>, ChannelRole)>
pub async fn set_channel_visibility( &self, channel_id: ChannelId, visibility: ChannelVisibility, admin_id: UserId ) -> Result<SetChannelVisibilityResult>
pub async fn delete_channel( &self, channel_id: ChannelId, user_id: UserId ) -> Result<(Vec<ChannelId>, Vec<UserId>)>
pub async fn invite_channel_member( &self, channel_id: ChannelId, invitee_id: UserId, inviter_id: UserId, role: ChannelRole ) -> Result<InviteMemberResult>
pub async fn rename_channel( &self, channel_id: ChannelId, admin_id: UserId, new_name: &str ) -> Result<RenameChannelResult>
pub async fn respond_to_channel_invite( &self, channel_id: ChannelId, user_id: UserId, accept: bool ) -> Result<RespondToChannelInvite>
pub async fn remove_channel_member( &self, channel_id: ChannelId, member_id: UserId, admin_id: UserId ) -> Result<RemoveChannelMemberResult>
pub async fn get_channel_invites_for_user( &self, user_id: UserId ) -> Result<Vec<Channel>>
pub async fn get_channels_for_user( &self, user_id: UserId ) -> Result<ChannelsForUser>
pub async fn get_user_channels( &self, user_id: UserId, ancestor_channel: Option<&Model>, tx: &DatabaseTransaction ) -> Result<ChannelsForUser>
pub async fn set_channel_member_role( &self, channel_id: ChannelId, admin_id: UserId, for_user: UserId, role: ChannelRole ) -> Result<SetMemberRoleResult>
pub async fn get_channel_participant_details( &self, channel_id: ChannelId, user_id: UserId ) -> Result<Vec<ChannelMember>>
pub async fn get_channel_participants( &self, channel: &Model, tx: &DatabaseTransaction ) -> Result<Vec<UserId>>
pub async fn check_user_is_channel_admin( &self, channel: &Model, user_id: UserId, tx: &DatabaseTransaction ) -> Result<ChannelRole>
pub async fn check_user_is_channel_member( &self, channel: &Model, user_id: UserId, tx: &DatabaseTransaction ) -> Result<ChannelRole>
pub async fn check_user_is_channel_participant( &self, channel: &Model, user_id: UserId, tx: &DatabaseTransaction ) -> Result<ChannelRole>
pub async fn pending_invite_for_channel( &self, channel: &Model, user_id: UserId, tx: &DatabaseTransaction ) -> Result<Option<Model>>
pub async fn public_parent_channel( &self, channel: &Model, tx: &DatabaseTransaction ) -> Result<Option<Model>>
pub async fn public_ancestors_including_self( &self, channel: &Model, tx: &DatabaseTransaction ) -> Result<Vec<Model>>
pub async fn channel_role_for_user( &self, channel: &Model, user_id: UserId, tx: &DatabaseTransaction ) -> Result<Option<ChannelRole>>
sourcepub async fn get_channel(
&self,
channel_id: ChannelId,
user_id: UserId
) -> Result<Channel>
pub async fn get_channel( &self, channel_id: ChannelId, user_id: UserId ) -> Result<Channel>
Returns the channel with the given ID
pub async fn get_channel_internal( &self, channel_id: ChannelId, tx: &DatabaseTransaction ) -> Result<Model>
sourcepub async fn move_channel(
&self,
channel_id: ChannelId,
new_parent_id: Option<ChannelId>,
admin_id: UserId
) -> Result<Option<MoveChannelResult>>
pub async fn move_channel( &self, channel_id: ChannelId, new_parent_id: Option<ChannelId>, admin_id: UserId ) -> Result<Option<MoveChannelResult>>
Move a channel from one parent to another
source§impl Database
impl Database
pub async fn get_contacts(&self, user_id: UserId) -> Result<Vec<Contact>>
pub async fn is_user_busy(&self, user_id: UserId) -> Result<bool>
pub async fn has_contact( &self, user_id_1: UserId, user_id_2: UserId ) -> Result<bool>
pub async fn send_contact_request( &self, sender_id: UserId, receiver_id: UserId ) -> Result<NotificationBatch>
sourcepub async fn remove_contact(
&self,
requester_id: UserId,
responder_id: UserId
) -> Result<(bool, Option<NotificationId>)>
pub async fn remove_contact( &self, requester_id: UserId, responder_id: UserId ) -> Result<(bool, Option<NotificationId>)>
Returns a bool indicating whether the removed contact had originally accepted or not
Deletes the contact identified by the requester and responder ids, and then returns whether the deleted contact had originally accepted or was a pending contact request.
Arguments
requester_id
- The user that initiates this requestresponder_id
- The user that will be removed
pub async fn dismiss_contact_notification( &self, user_id: UserId, contact_user_id: UserId ) -> Result<()>
pub async fn respond_to_contact_request( &self, responder_id: UserId, requester_id: UserId, accept: bool ) -> Result<NotificationBatch>
source§impl Database
impl Database
pub async fn join_channel_chat( &self, channel_id: ChannelId, connection_id: ConnectionId, user_id: UserId ) -> Result<()>
pub async fn channel_chat_connection_lost( &self, connection_id: ConnectionId, tx: &DatabaseTransaction ) -> Result<()>
pub async fn leave_channel_chat( &self, channel_id: ChannelId, connection_id: ConnectionId, _user_id: UserId ) -> Result<()>
pub async fn get_channel_messages( &self, channel_id: ChannelId, user_id: UserId, count: usize, before_message_id: Option<MessageId> ) -> Result<Vec<ChannelMessage>>
pub async fn get_channel_messages_by_id( &self, user_id: UserId, message_ids: &[MessageId] ) -> Result<Vec<ChannelMessage>>
pub async fn create_channel_message( &self, channel_id: ChannelId, user_id: UserId, body: &str, mentions: &[ChatMention], timestamp: OffsetDateTime, nonce: u128 ) -> Result<CreatedChannelMessage>
pub async fn observe_channel_message( &self, channel_id: ChannelId, user_id: UserId, message_id: MessageId ) -> Result<NotificationBatch>
pub async fn unseen_channel_messages( &self, user_id: UserId, channel_ids: &[ChannelId], tx: &DatabaseTransaction ) -> Result<Vec<UnseenChannelMessage>>
pub async fn remove_channel_message( &self, channel_id: ChannelId, message_id: MessageId, user_id: UserId ) -> Result<Vec<ConnectionId>>
source§impl Database
impl Database
pub async fn initialize_notification_kinds(&mut self) -> Result<()>
pub async fn get_notifications( &self, recipient_id: UserId, limit: usize, before_id: Option<NotificationId> ) -> Result<Vec<Notification>>
sourcepub async fn create_notification(
&self,
recipient_id: UserId,
notification: Notification,
avoid_duplicates: bool,
tx: &DatabaseTransaction
) -> Result<Option<(UserId, Notification)>>
pub async fn create_notification( &self, recipient_id: UserId, notification: Notification, avoid_duplicates: bool, tx: &DatabaseTransaction ) -> Result<Option<(UserId, Notification)>>
Create a notification. If avoid_duplicates
is set to true, then avoid
creating a new notification if the given recipient already has an
unread notification with the given kind and entity id.
sourcepub async fn remove_notification(
&self,
recipient_id: UserId,
notification: Notification,
tx: &DatabaseTransaction
) -> Result<Option<NotificationId>>
pub async fn remove_notification( &self, recipient_id: UserId, notification: Notification, tx: &DatabaseTransaction ) -> Result<Option<NotificationId>>
Remove an unread notification with the given recipient, kind and entity id.
sourcepub async fn mark_notification_as_read_with_response(
&self,
recipient_id: UserId,
notification: &Notification,
response: bool,
tx: &DatabaseTransaction
) -> Result<Option<(UserId, Notification)>>
pub async fn mark_notification_as_read_with_response( &self, recipient_id: UserId, notification: &Notification, response: bool, tx: &DatabaseTransaction ) -> Result<Option<(UserId, Notification)>>
Populate the response for the notification with the given kind and entity id.
pub async fn mark_notification_as_read( &self, recipient_id: UserId, notification: &Notification, tx: &DatabaseTransaction ) -> Result<Option<(UserId, Notification)>>
pub async fn mark_notification_as_read_by_id( &self, recipient_id: UserId, notification_id: NotificationId ) -> Result<NotificationBatch>
source§impl Database
impl Database
pub async fn project_count_excluding_admins(&self) -> Result<usize>
pub async fn update_project( &self, project_id: ProjectId, connection: ConnectionId, worktrees: &[WorktreeMetadata] ) -> Result<RoomGuard<(Room, Vec<ConnectionId>)>>
pub async fn update_worktree( &self, update: &UpdateWorktree, connection: ConnectionId ) -> Result<RoomGuard<Vec<ConnectionId>>>
pub async fn update_diagnostic_summary( &self, update: &UpdateDiagnosticSummary, connection: ConnectionId ) -> Result<RoomGuard<Vec<ConnectionId>>>
pub async fn start_language_server( &self, update: &StartLanguageServer, connection: ConnectionId ) -> Result<RoomGuard<Vec<ConnectionId>>>
pub async fn update_worktree_settings( &self, update: &UpdateWorktreeSettings, connection: ConnectionId ) -> Result<RoomGuard<Vec<ConnectionId>>>
pub async fn join_project( &self, project_id: ProjectId, connection: ConnectionId ) -> Result<RoomGuard<(Project, ReplicaId)>>
pub async fn leave_project( &self, project_id: ProjectId, connection: ConnectionId ) -> Result<RoomGuard<(Room, LeftProject)>>
pub async fn project_collaborators( &self, project_id: ProjectId, connection_id: ConnectionId ) -> Result<RoomGuard<Vec<ProjectCollaborator>>>
pub async fn project_connection_ids( &self, project_id: ProjectId, connection_id: ConnectionId ) -> Result<RoomGuard<HashSet<ConnectionId>>>
pub async fn room_id_for_project(&self, project_id: ProjectId) -> Result<RoomId>
pub async fn check_room_participants( &self, room_id: RoomId, leader_id: ConnectionId, follower_id: ConnectionId ) -> Result<()>
pub async fn follow( &self, room_id: RoomId, project_id: ProjectId, leader_connection: ConnectionId, follower_connection: ConnectionId ) -> Result<RoomGuard<Room>>
pub async fn unfollow( &self, room_id: RoomId, project_id: ProjectId, leader_connection: ConnectionId, follower_connection: ConnectionId ) -> Result<RoomGuard<Room>>
source§impl Database
impl Database
pub async fn clear_stale_room_participants( &self, room_id: RoomId, new_server_id: ServerId ) -> Result<RoomGuard<RefreshedRoom>>
pub async fn incoming_call_for_user( &self, user_id: UserId ) -> Result<Option<IncomingCall>>
pub async fn create_room( &self, user_id: UserId, connection: ConnectionId, live_kit_room: &str, release_channel: &str ) -> Result<Room>
pub async fn call( &self, room_id: RoomId, calling_user_id: UserId, calling_connection: ConnectionId, called_user_id: UserId, initial_project_id: Option<ProjectId> ) -> Result<RoomGuard<(Room, IncomingCall)>>
pub async fn call_failed( &self, room_id: RoomId, called_user_id: UserId ) -> Result<RoomGuard<Room>>
pub async fn decline_call( &self, expected_room_id: Option<RoomId>, user_id: UserId ) -> Result<Option<RoomGuard<Room>>>
pub async fn cancel_call( &self, room_id: RoomId, calling_connection: ConnectionId, called_user_id: UserId ) -> Result<RoomGuard<Room>>
pub async fn join_room( &self, room_id: RoomId, user_id: UserId, connection: ConnectionId, enviroment: &str ) -> Result<RoomGuard<JoinRoom>>
pub async fn channel_id_for_room( &self, room_id: RoomId ) -> Result<Option<ChannelId>>
pub async fn rejoin_room( &self, rejoin_room: RejoinRoom, user_id: UserId, connection: ConnectionId ) -> Result<RoomGuard<RejoinedRoom>>
pub async fn leave_room( &self, connection: ConnectionId ) -> Result<Option<RoomGuard<LeftRoom>>>
pub async fn update_room_participant_location( &self, room_id: RoomId, connection: ConnectionId, location: ParticipantLocation ) -> Result<RoomGuard<Room>>
pub async fn connection_lost(&self, connection: ConnectionId) -> Result<()>
pub async fn room_connection_lost( &self, connection: ConnectionId, tx: &DatabaseTransaction ) -> Result<()>
pub async fn get_room( &self, room_id: RoomId, tx: &DatabaseTransaction ) -> Result<Room>
pub async fn room_connection_ids( &self, room_id: RoomId, connection_id: ConnectionId ) -> Result<RoomGuard<HashSet<ConnectionId>>>
source§impl Database
impl Database
pub async fn create_server(&self, environment: &str) -> Result<ServerId>
pub async fn stale_server_resource_ids( &self, environment: &str, new_server_id: ServerId ) -> Result<(Vec<RoomId>, Vec<ChannelId>)>
pub async fn delete_stale_servers( &self, environment: &str, new_server_id: ServerId ) -> Result<()>
source§impl Database
impl Database
pub async fn create_user( &self, email_address: &str, admin: bool, params: NewUserParams ) -> Result<NewUserResult>
pub async fn get_user_by_id(&self, id: UserId) -> Result<Option<Model>>
pub async fn get_users_by_ids(&self, ids: Vec<UserId>) -> Result<Vec<Model>>
pub async fn get_user_by_github_login( &self, github_login: &str ) -> Result<Option<User>>
pub async fn get_or_create_user_by_github_account( &self, github_login: &str, github_user_id: Option<i32>, github_email: Option<&str> ) -> Result<Option<User>>
pub async fn get_all_users(&self, page: u32, limit: u32) -> Result<Vec<User>>
pub async fn get_user_metrics_id(&self, id: UserId) -> Result<String>
pub async fn set_user_connected_once( &self, id: UserId, connected_once: bool ) -> Result<()>
pub async fn destroy_user(&self, id: UserId) -> Result<()>
pub async fn fuzzy_search_users( &self, name_query: &str, limit: u32 ) -> Result<Vec<User>>
pub fn fuzzy_like_string(string: &str) -> String
pub async fn create_user_flag(&self, flag: &str) -> Result<FlagId>
pub async fn add_user_flag(&self, user: UserId, flag: FlagId) -> Result<()>
pub async fn get_user_flags(&self, user: UserId) -> Result<Vec<String>>
source§impl Database
impl Database
pub async fn new(options: ConnectOptions, executor: Executor) -> Result<Self>
pub async fn migrate( &self, migrations_path: &Path, ignore_checksum_mismatch: bool ) -> Result<Vec<(Migration, Duration)>>
pub async fn initialize_static_data(&mut self) -> Result<()>
pub async fn transaction<F, Fut, T>(&self, f: F) -> Result<T>where F: Send + Fn(TransactionHandle) -> Fut, Fut: Send + Future<Output = Result<T>>,
Auto Trait Implementations§
impl !RefUnwindSafe for Database
impl Send for Database
impl Sync for Database
impl Unpin for Database
impl !UnwindSafe for Database
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more