bugfixing
This commit is contained in:
parent
b66a4e63f1
commit
3457e0d024
13 changed files with 495 additions and 444 deletions
|
|
@ -1,190 +0,0 @@
|
|||
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
|
||||
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
|
||||
|
||||
#![allow(unused, clippy::all)]
|
||||
use super::lobby_timer_type::LobbyTimer;
|
||||
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
|
||||
|
||||
/// Table handle for the table `game_timer`.
|
||||
///
|
||||
/// Obtain a handle from the [`GameTimerTableAccess::game_timer`] method on [`super::RemoteTables`],
|
||||
/// like `ctx.db.game_timer()`.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.game_timer().on_insert(...)`.
|
||||
pub struct GameTimerTableHandle<'ctx> {
|
||||
imp: __sdk::TableHandle<LobbyTimer>,
|
||||
ctx: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for access to the table `game_timer`.
|
||||
///
|
||||
/// Implemented for [`super::RemoteTables`].
|
||||
pub trait GameTimerTableAccess {
|
||||
#[allow(non_snake_case)]
|
||||
/// Obtain a [`GameTimerTableHandle`], which mediates access to the table `game_timer`.
|
||||
fn game_timer(&self) -> GameTimerTableHandle<'_>;
|
||||
}
|
||||
|
||||
impl GameTimerTableAccess for super::RemoteTables {
|
||||
fn game_timer(&self) -> GameTimerTableHandle<'_> {
|
||||
GameTimerTableHandle {
|
||||
imp: self.imp.get_table::<LobbyTimer>("game_timer"),
|
||||
ctx: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct GameTimerInsertCallbackId(__sdk::CallbackId);
|
||||
pub struct GameTimerDeleteCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::Table for GameTimerTableHandle<'ctx> {
|
||||
type Row = LobbyTimer;
|
||||
type EventContext = super::EventContext;
|
||||
|
||||
fn count(&self) -> u64 {
|
||||
self.imp.count()
|
||||
}
|
||||
fn iter(&self) -> impl Iterator<Item = LobbyTimer> + '_ {
|
||||
self.imp.iter()
|
||||
}
|
||||
|
||||
type InsertCallbackId = GameTimerInsertCallbackId;
|
||||
|
||||
fn on_insert(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
|
||||
) -> GameTimerInsertCallbackId {
|
||||
GameTimerInsertCallbackId(self.imp.on_insert(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_insert(&self, callback: GameTimerInsertCallbackId) {
|
||||
self.imp.remove_on_insert(callback.0)
|
||||
}
|
||||
|
||||
type DeleteCallbackId = GameTimerDeleteCallbackId;
|
||||
|
||||
fn on_delete(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
|
||||
) -> GameTimerDeleteCallbackId {
|
||||
GameTimerDeleteCallbackId(self.imp.on_delete(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_delete(&self, callback: GameTimerDeleteCallbackId) {
|
||||
self.imp.remove_on_delete(callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct GameTimerUpdateCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::TableWithPrimaryKey for GameTimerTableHandle<'ctx> {
|
||||
type UpdateCallbackId = GameTimerUpdateCallbackId;
|
||||
|
||||
fn on_update(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row, &Self::Row) + Send + 'static,
|
||||
) -> GameTimerUpdateCallbackId {
|
||||
GameTimerUpdateCallbackId(self.imp.on_update(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_update(&self, callback: GameTimerUpdateCallbackId) {
|
||||
self.imp.remove_on_update(callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
/// Access to the `lobby_id` unique index on the table `game_timer`,
|
||||
/// which allows point queries on the field of the same name
|
||||
/// via the [`GameTimerLobbyIdUnique::find`] method.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.game_timer().lobby_id().find(...)`.
|
||||
pub struct GameTimerLobbyIdUnique<'ctx> {
|
||||
imp: __sdk::UniqueConstraintHandle<LobbyTimer, u32>,
|
||||
phantom: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
impl<'ctx> GameTimerTableHandle<'ctx> {
|
||||
/// Get a handle on the `lobby_id` unique index on the table `game_timer`.
|
||||
pub fn lobby_id(&self) -> GameTimerLobbyIdUnique<'ctx> {
|
||||
GameTimerLobbyIdUnique {
|
||||
imp: self.imp.get_unique_constraint::<u32>("lobby_id"),
|
||||
phantom: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'ctx> GameTimerLobbyIdUnique<'ctx> {
|
||||
/// Find the subscribed row whose `lobby_id` column value is equal to `col_val`,
|
||||
/// if such a row is present in the client cache.
|
||||
pub fn find(&self, col_val: &u32) -> Option<LobbyTimer> {
|
||||
self.imp.find(col_val)
|
||||
}
|
||||
}
|
||||
|
||||
/// Access to the `scheduled_id` unique index on the table `game_timer`,
|
||||
/// which allows point queries on the field of the same name
|
||||
/// via the [`GameTimerScheduledIdUnique::find`] method.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.game_timer().scheduled_id().find(...)`.
|
||||
pub struct GameTimerScheduledIdUnique<'ctx> {
|
||||
imp: __sdk::UniqueConstraintHandle<LobbyTimer, u64>,
|
||||
phantom: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
impl<'ctx> GameTimerTableHandle<'ctx> {
|
||||
/// Get a handle on the `scheduled_id` unique index on the table `game_timer`.
|
||||
pub fn scheduled_id(&self) -> GameTimerScheduledIdUnique<'ctx> {
|
||||
GameTimerScheduledIdUnique {
|
||||
imp: self.imp.get_unique_constraint::<u64>("scheduled_id"),
|
||||
phantom: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'ctx> GameTimerScheduledIdUnique<'ctx> {
|
||||
/// Find the subscribed row whose `scheduled_id` column value is equal to `col_val`,
|
||||
/// if such a row is present in the client cache.
|
||||
pub fn find(&self, col_val: &u64) -> Option<LobbyTimer> {
|
||||
self.imp.find(col_val)
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn register_table(client_cache: &mut __sdk::ClientCache<super::RemoteModule>) {
|
||||
let _table = client_cache.get_or_make_table::<LobbyTimer>("game_timer");
|
||||
_table.add_unique_constraint::<u32>("lobby_id", |row| &row.lobby_id);
|
||||
_table.add_unique_constraint::<u64>("scheduled_id", |row| &row.scheduled_id);
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn parse_table_update(
|
||||
raw_updates: __ws::v2::TableUpdate,
|
||||
) -> __sdk::Result<__sdk::TableUpdate<LobbyTimer>> {
|
||||
__sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| {
|
||||
__sdk::InternalError::failed_parse("TableUpdate<LobbyTimer>", "TableUpdate")
|
||||
.with_cause(e)
|
||||
.into()
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for query builder access to the table `LobbyTimer`.
|
||||
///
|
||||
/// Implemented for [`__sdk::QueryTableAccessor`].
|
||||
pub trait game_timerQueryTableAccess {
|
||||
#[allow(non_snake_case)]
|
||||
/// Get a query builder for the table `LobbyTimer`.
|
||||
fn game_timer(&self) -> __sdk::__query_builder::Table<LobbyTimer>;
|
||||
}
|
||||
|
||||
impl game_timerQueryTableAccess for __sdk::QueryTableAccessor {
|
||||
fn game_timer(&self) -> __sdk::__query_builder::Table<LobbyTimer> {
|
||||
__sdk::__query_builder::Table::new("game_timer")
|
||||
}
|
||||
}
|
||||
|
|
@ -14,7 +14,6 @@ pub mod db_tile_type;
|
|||
pub mod discard_tile_reducer;
|
||||
pub mod dragon_type;
|
||||
pub mod game_state_type;
|
||||
pub mod game_timer_table;
|
||||
pub mod hand_view_type;
|
||||
pub mod join_or_create_lobby_reducer;
|
||||
pub mod lobby_table;
|
||||
|
|
@ -30,6 +29,7 @@ pub mod set_ready_reducer;
|
|||
pub mod suit_type;
|
||||
pub mod tile_type;
|
||||
pub mod turn_state_type;
|
||||
pub mod user_table;
|
||||
pub mod user_type;
|
||||
pub mod view_closed_hands_table;
|
||||
pub mod view_hand_table;
|
||||
|
|
@ -44,7 +44,6 @@ pub use db_tile_type::DbTile;
|
|||
pub use discard_tile_reducer::discard_tile;
|
||||
pub use dragon_type::Dragon;
|
||||
pub use game_state_type::GameState;
|
||||
pub use game_timer_table::*;
|
||||
pub use hand_view_type::HandView;
|
||||
pub use join_or_create_lobby_reducer::join_or_create_lobby;
|
||||
pub use lobby_table::*;
|
||||
|
|
@ -60,6 +59,7 @@ pub use set_ready_reducer::set_ready;
|
|||
pub use suit_type::Suit;
|
||||
pub use tile_type::Tile;
|
||||
pub use turn_state_type::TurnState;
|
||||
pub use user_table::*;
|
||||
pub use user_type::User;
|
||||
pub use view_closed_hands_table::*;
|
||||
pub use view_hand_table::*;
|
||||
|
|
@ -130,10 +130,10 @@ impl __sdk::Reducer for Reducer {
|
|||
#[doc(hidden)]
|
||||
pub struct DbUpdate {
|
||||
bot: __sdk::TableUpdate<Bot>,
|
||||
game_timer: __sdk::TableUpdate<LobbyTimer>,
|
||||
lobby: __sdk::TableUpdate<Lobby>,
|
||||
player_clock: __sdk::TableUpdate<PlayerClock>,
|
||||
player_config: __sdk::TableUpdate<PlayerConfig>,
|
||||
user: __sdk::TableUpdate<User>,
|
||||
view_closed_hands: __sdk::TableUpdate<HandView>,
|
||||
view_hand: __sdk::TableUpdate<PlayerHand>,
|
||||
}
|
||||
|
|
@ -147,9 +147,6 @@ impl TryFrom<__ws::v2::TransactionUpdate> for DbUpdate {
|
|||
"bot" => db_update
|
||||
.bot
|
||||
.append(bot_table::parse_table_update(table_update)?),
|
||||
"game_timer" => db_update
|
||||
.game_timer
|
||||
.append(game_timer_table::parse_table_update(table_update)?),
|
||||
"lobby" => db_update
|
||||
.lobby
|
||||
.append(lobby_table::parse_table_update(table_update)?),
|
||||
|
|
@ -159,6 +156,9 @@ impl TryFrom<__ws::v2::TransactionUpdate> for DbUpdate {
|
|||
"player_config" => db_update
|
||||
.player_config
|
||||
.append(player_config_table::parse_table_update(table_update)?),
|
||||
"user" => db_update
|
||||
.user
|
||||
.append(user_table::parse_table_update(table_update)?),
|
||||
"view_closed_hands" => db_update
|
||||
.view_closed_hands
|
||||
.append(view_closed_hands_table::parse_table_update(table_update)?),
|
||||
|
|
@ -194,9 +194,6 @@ impl __sdk::DbUpdate for DbUpdate {
|
|||
diff.bot = cache
|
||||
.apply_diff_to_table::<Bot>("bot", &self.bot)
|
||||
.with_updates_by_pk(|row| &row.id);
|
||||
diff.game_timer = cache
|
||||
.apply_diff_to_table::<LobbyTimer>("game_timer", &self.game_timer)
|
||||
.with_updates_by_pk(|row| &row.scheduled_id);
|
||||
diff.lobby = cache
|
||||
.apply_diff_to_table::<Lobby>("lobby", &self.lobby)
|
||||
.with_updates_by_pk(|row| &row.id);
|
||||
|
|
@ -206,6 +203,9 @@ impl __sdk::DbUpdate for DbUpdate {
|
|||
diff.player_config = cache
|
||||
.apply_diff_to_table::<PlayerConfig>("player_config", &self.player_config)
|
||||
.with_updates_by_pk(|row| &row.id);
|
||||
diff.user = cache
|
||||
.apply_diff_to_table::<User>("user", &self.user)
|
||||
.with_updates_by_pk(|row| &row.identity);
|
||||
diff.view_closed_hands =
|
||||
cache.apply_diff_to_table::<HandView>("view_closed_hands", &self.view_closed_hands);
|
||||
diff.view_hand = cache.apply_diff_to_table::<PlayerHand>("view_hand", &self.view_hand);
|
||||
|
|
@ -219,9 +219,6 @@ impl __sdk::DbUpdate for DbUpdate {
|
|||
"bot" => db_update
|
||||
.bot
|
||||
.append(__sdk::parse_row_list_as_inserts(table_rows.rows)?),
|
||||
"game_timer" => db_update
|
||||
.game_timer
|
||||
.append(__sdk::parse_row_list_as_inserts(table_rows.rows)?),
|
||||
"lobby" => db_update
|
||||
.lobby
|
||||
.append(__sdk::parse_row_list_as_inserts(table_rows.rows)?),
|
||||
|
|
@ -231,6 +228,9 @@ impl __sdk::DbUpdate for DbUpdate {
|
|||
"player_config" => db_update
|
||||
.player_config
|
||||
.append(__sdk::parse_row_list_as_inserts(table_rows.rows)?),
|
||||
"user" => db_update
|
||||
.user
|
||||
.append(__sdk::parse_row_list_as_inserts(table_rows.rows)?),
|
||||
"view_closed_hands" => db_update
|
||||
.view_closed_hands
|
||||
.append(__sdk::parse_row_list_as_inserts(table_rows.rows)?),
|
||||
|
|
@ -253,9 +253,6 @@ impl __sdk::DbUpdate for DbUpdate {
|
|||
"bot" => db_update
|
||||
.bot
|
||||
.append(__sdk::parse_row_list_as_deletes(table_rows.rows)?),
|
||||
"game_timer" => db_update
|
||||
.game_timer
|
||||
.append(__sdk::parse_row_list_as_deletes(table_rows.rows)?),
|
||||
"lobby" => db_update
|
||||
.lobby
|
||||
.append(__sdk::parse_row_list_as_deletes(table_rows.rows)?),
|
||||
|
|
@ -265,6 +262,9 @@ impl __sdk::DbUpdate for DbUpdate {
|
|||
"player_config" => db_update
|
||||
.player_config
|
||||
.append(__sdk::parse_row_list_as_deletes(table_rows.rows)?),
|
||||
"user" => db_update
|
||||
.user
|
||||
.append(__sdk::parse_row_list_as_deletes(table_rows.rows)?),
|
||||
"view_closed_hands" => db_update
|
||||
.view_closed_hands
|
||||
.append(__sdk::parse_row_list_as_deletes(table_rows.rows)?),
|
||||
|
|
@ -287,10 +287,10 @@ impl __sdk::DbUpdate for DbUpdate {
|
|||
#[doc(hidden)]
|
||||
pub struct AppliedDiff<'r> {
|
||||
bot: __sdk::TableAppliedDiff<'r, Bot>,
|
||||
game_timer: __sdk::TableAppliedDiff<'r, LobbyTimer>,
|
||||
lobby: __sdk::TableAppliedDiff<'r, Lobby>,
|
||||
player_clock: __sdk::TableAppliedDiff<'r, PlayerClock>,
|
||||
player_config: __sdk::TableAppliedDiff<'r, PlayerConfig>,
|
||||
user: __sdk::TableAppliedDiff<'r, User>,
|
||||
view_closed_hands: __sdk::TableAppliedDiff<'r, HandView>,
|
||||
view_hand: __sdk::TableAppliedDiff<'r, PlayerHand>,
|
||||
__unused: std::marker::PhantomData<&'r ()>,
|
||||
|
|
@ -307,7 +307,6 @@ impl<'r> __sdk::AppliedDiff<'r> for AppliedDiff<'r> {
|
|||
callbacks: &mut __sdk::DbCallbacks<RemoteModule>,
|
||||
) {
|
||||
callbacks.invoke_table_row_callbacks::<Bot>("bot", &self.bot, event);
|
||||
callbacks.invoke_table_row_callbacks::<LobbyTimer>("game_timer", &self.game_timer, event);
|
||||
callbacks.invoke_table_row_callbacks::<Lobby>("lobby", &self.lobby, event);
|
||||
callbacks.invoke_table_row_callbacks::<PlayerClock>(
|
||||
"player_clock",
|
||||
|
|
@ -319,6 +318,7 @@ impl<'r> __sdk::AppliedDiff<'r> for AppliedDiff<'r> {
|
|||
&self.player_config,
|
||||
event,
|
||||
);
|
||||
callbacks.invoke_table_row_callbacks::<User>("user", &self.user, event);
|
||||
callbacks.invoke_table_row_callbacks::<HandView>(
|
||||
"view_closed_hands",
|
||||
&self.view_closed_hands,
|
||||
|
|
@ -970,19 +970,19 @@ impl __sdk::SpacetimeModule for RemoteModule {
|
|||
|
||||
fn register_tables(client_cache: &mut __sdk::ClientCache<Self>) {
|
||||
bot_table::register_table(client_cache);
|
||||
game_timer_table::register_table(client_cache);
|
||||
lobby_table::register_table(client_cache);
|
||||
player_clock_table::register_table(client_cache);
|
||||
player_config_table::register_table(client_cache);
|
||||
user_table::register_table(client_cache);
|
||||
view_closed_hands_table::register_table(client_cache);
|
||||
view_hand_table::register_table(client_cache);
|
||||
}
|
||||
const ALL_TABLE_NAMES: &'static [&'static str] = &[
|
||||
"bot",
|
||||
"game_timer",
|
||||
"lobby",
|
||||
"player_clock",
|
||||
"player_config",
|
||||
"user",
|
||||
"view_closed_hands",
|
||||
"view_hand",
|
||||
];
|
||||
|
|
|
|||
192
jong-db/src/db/user_table.rs
Normal file
192
jong-db/src/db/user_table.rs
Normal file
|
|
@ -0,0 +1,192 @@
|
|||
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
|
||||
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
|
||||
|
||||
#![allow(unused, clippy::all)]
|
||||
use super::user_type::User;
|
||||
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
|
||||
|
||||
/// Table handle for the table `user`.
|
||||
///
|
||||
/// Obtain a handle from the [`UserTableAccess::user`] method on [`super::RemoteTables`],
|
||||
/// like `ctx.db.user()`.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.user().on_insert(...)`.
|
||||
pub struct UserTableHandle<'ctx> {
|
||||
imp: __sdk::TableHandle<User>,
|
||||
ctx: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for access to the table `user`.
|
||||
///
|
||||
/// Implemented for [`super::RemoteTables`].
|
||||
pub trait UserTableAccess {
|
||||
#[allow(non_snake_case)]
|
||||
/// Obtain a [`UserTableHandle`], which mediates access to the table `user`.
|
||||
fn user(&self) -> UserTableHandle<'_>;
|
||||
}
|
||||
|
||||
impl UserTableAccess for super::RemoteTables {
|
||||
fn user(&self) -> UserTableHandle<'_> {
|
||||
UserTableHandle {
|
||||
imp: self.imp.get_table::<User>("user"),
|
||||
ctx: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct UserInsertCallbackId(__sdk::CallbackId);
|
||||
pub struct UserDeleteCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::Table for UserTableHandle<'ctx> {
|
||||
type Row = User;
|
||||
type EventContext = super::EventContext;
|
||||
|
||||
fn count(&self) -> u64 {
|
||||
self.imp.count()
|
||||
}
|
||||
fn iter(&self) -> impl Iterator<Item = User> + '_ {
|
||||
self.imp.iter()
|
||||
}
|
||||
|
||||
type InsertCallbackId = UserInsertCallbackId;
|
||||
|
||||
fn on_insert(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
|
||||
) -> UserInsertCallbackId {
|
||||
UserInsertCallbackId(self.imp.on_insert(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_insert(&self, callback: UserInsertCallbackId) {
|
||||
self.imp.remove_on_insert(callback.0)
|
||||
}
|
||||
|
||||
type DeleteCallbackId = UserDeleteCallbackId;
|
||||
|
||||
fn on_delete(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
|
||||
) -> UserDeleteCallbackId {
|
||||
UserDeleteCallbackId(self.imp.on_delete(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_delete(&self, callback: UserDeleteCallbackId) {
|
||||
self.imp.remove_on_delete(callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct UserUpdateCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::TableWithPrimaryKey for UserTableHandle<'ctx> {
|
||||
type UpdateCallbackId = UserUpdateCallbackId;
|
||||
|
||||
fn on_update(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row, &Self::Row) + Send + 'static,
|
||||
) -> UserUpdateCallbackId {
|
||||
UserUpdateCallbackId(self.imp.on_update(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_update(&self, callback: UserUpdateCallbackId) {
|
||||
self.imp.remove_on_update(callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
/// Access to the `identity` unique index on the table `user`,
|
||||
/// which allows point queries on the field of the same name
|
||||
/// via the [`UserIdentityUnique::find`] method.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.user().identity().find(...)`.
|
||||
pub struct UserIdentityUnique<'ctx> {
|
||||
imp: __sdk::UniqueConstraintHandle<User, __sdk::Identity>,
|
||||
phantom: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
impl<'ctx> UserTableHandle<'ctx> {
|
||||
/// Get a handle on the `identity` unique index on the table `user`.
|
||||
pub fn identity(&self) -> UserIdentityUnique<'ctx> {
|
||||
UserIdentityUnique {
|
||||
imp: self
|
||||
.imp
|
||||
.get_unique_constraint::<__sdk::Identity>("identity"),
|
||||
phantom: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'ctx> UserIdentityUnique<'ctx> {
|
||||
/// Find the subscribed row whose `identity` column value is equal to `col_val`,
|
||||
/// if such a row is present in the client cache.
|
||||
pub fn find(&self, col_val: &__sdk::Identity) -> Option<User> {
|
||||
self.imp.find(col_val)
|
||||
}
|
||||
}
|
||||
|
||||
/// Access to the `config_id` unique index on the table `user`,
|
||||
/// which allows point queries on the field of the same name
|
||||
/// via the [`UserConfigIdUnique::find`] method.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.user().config_id().find(...)`.
|
||||
pub struct UserConfigIdUnique<'ctx> {
|
||||
imp: __sdk::UniqueConstraintHandle<User, u32>,
|
||||
phantom: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
impl<'ctx> UserTableHandle<'ctx> {
|
||||
/// Get a handle on the `config_id` unique index on the table `user`.
|
||||
pub fn config_id(&self) -> UserConfigIdUnique<'ctx> {
|
||||
UserConfigIdUnique {
|
||||
imp: self.imp.get_unique_constraint::<u32>("config_id"),
|
||||
phantom: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'ctx> UserConfigIdUnique<'ctx> {
|
||||
/// Find the subscribed row whose `config_id` column value is equal to `col_val`,
|
||||
/// if such a row is present in the client cache.
|
||||
pub fn find(&self, col_val: &u32) -> Option<User> {
|
||||
self.imp.find(col_val)
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn register_table(client_cache: &mut __sdk::ClientCache<super::RemoteModule>) {
|
||||
let _table = client_cache.get_or_make_table::<User>("user");
|
||||
_table.add_unique_constraint::<__sdk::Identity>("identity", |row| &row.identity);
|
||||
_table.add_unique_constraint::<u32>("config_id", |row| &row.config_id);
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn parse_table_update(
|
||||
raw_updates: __ws::v2::TableUpdate,
|
||||
) -> __sdk::Result<__sdk::TableUpdate<User>> {
|
||||
__sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| {
|
||||
__sdk::InternalError::failed_parse("TableUpdate<User>", "TableUpdate")
|
||||
.with_cause(e)
|
||||
.into()
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for query builder access to the table `User`.
|
||||
///
|
||||
/// Implemented for [`__sdk::QueryTableAccessor`].
|
||||
pub trait userQueryTableAccess {
|
||||
#[allow(non_snake_case)]
|
||||
/// Get a query builder for the table `User`.
|
||||
fn user(&self) -> __sdk::__query_builder::Table<User>;
|
||||
}
|
||||
|
||||
impl userQueryTableAccess for __sdk::QueryTableAccessor {
|
||||
fn user(&self) -> __sdk::__query_builder::Table<User> {
|
||||
__sdk::__query_builder::Table::new("user")
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue