-
Notifications
You must be signed in to change notification settings - Fork 295
Description
Is your feature request related to a problem? Please describe.
I am building a local-first mobile application (React Native) involving high-frequency data (messaging) where we need to sync a "sliding window" of recent activity (e.g., messages WHERE created_at > 30 days ago).
The problem is Data Hydration (orphaned Foreign Keys). When we sync the last 30 days of messages, we also need the Conversation and Customer rows associated with those messages to render the UI. However:
- The
Conversationmight be 2 years old (outside the sync window). - Syncing all
Conversationsis not feasible (dataset too large). - We cannot easily identify which old conversations to fetch without first fetching the messages.
This leaves us with orphaned foreign keys on the client and a broken UI.
Describe the solution you'd like
I would like a mechanism to define Dependent Shapes or Include Trees where the presence of a child row in a shape forces the sync of its parent row, regardless of the parent's timestamp.
Ideal Syntax (Conceptual):
const { data } = useShape({
table: 'messages',
where: `created_at >= now() - interval '30 days'`,
include: {
// Automatically fetch the specific Conversation row referenced by messages.conversation_id
conversation: {
include: {
// And the Customer referenced by that conversation
customer: true
}
}
}
})
I understand include was removed in v1.0, but the use case for "Graph Sync" remains critical for partial replication.
Additional context
- Stack: Postgres -> ElectricSQL -> SQLite