Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/react/todo/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ const createTodoCollection = (type: CollectionType) => {
if (type === CollectionType.Electric) {
newCollection = createElectricCollection<UpdateTodo>({
id: `todos`,
streamOptions: {
shapeOptions: {
url: `http://localhost:3003/v1/shape`,
params: {
table: `todos`,
Expand Down Expand Up @@ -186,7 +186,7 @@ const createConfigCollection = (type: CollectionType) => {
if (type === CollectionType.Electric) {
newCollection = createElectricCollection<UpdateConfig>({
id: `config`,
streamOptions: {
shapeOptions: {
url: `http://localhost:3003/v1/shape`,
params: {
table: `config`,
Expand Down
14 changes: 7 additions & 7 deletions packages/db-collections/src/electric.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export interface ElectricCollectionConfig<T extends Row<unknown>>
/**
* Configuration options for the ElectricSQL ShapeStream
*/
streamOptions: ShapeStreamOptions
shapeOptions: ShapeStreamOptions
}

/**
Expand All @@ -34,7 +34,7 @@ export class ElectricCollection<

constructor(config: ElectricCollectionConfig<T>) {
const seenTxids = new Store<Set<number>>(new Set([Math.random()]))
const sync = createElectricSync<T>(config.streamOptions, {
const sync = createElectricSync<T>(config.shapeOptions, {
seenTxids,
})

Expand Down Expand Up @@ -90,7 +90,7 @@ function hasTxids<T extends Row<unknown> = Row>(
/**
* Creates an ElectricSQL sync configuration
*
* @param streamOptions - Configuration options for the ShapeStream
* @param shapeOptions - Configuration options for the ShapeStream
* @param options - Options for the ElectricSync configuration
* @returns ElectricSync configuration
*/
Expand All @@ -107,7 +107,7 @@ export function createElectricCollection<T extends Row<unknown>>(
* Internal function to create ElectricSQL sync configuration
*/
function createElectricSync<T extends Row<unknown>>(
streamOptions: ShapeStreamOptions,
shapeOptions: ShapeStreamOptions,
options: {
seenTxids: Store<Set<number>>
}
Expand All @@ -126,16 +126,16 @@ function createElectricSync<T extends Row<unknown>>(
const schema = relationSchema.state || `public`

return {
relation: streamOptions.params?.table
? [schema, streamOptions.params.table]
relation: shapeOptions.params?.table
? [schema, shapeOptions.params.table]
: undefined,
}
}

return {
sync: (params: Parameters<SyncConfig<T>[`sync`]>[0]) => {
const { begin, write, commit } = params
const stream = new ShapeStream(streamOptions)
const stream = new ShapeStream(shapeOptions)
let transactionStarted = false
let newTxids = new Set<number>()

Expand Down
2 changes: 1 addition & 1 deletion packages/db-collections/tests/electric.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe(`Electric Integration`, () => {
// Create collection with Electric configuration
collection = createElectricCollection({
id: `test`,
streamOptions: {
shapeOptions: {
url: `http://test-url`,
params: {
table: `test_table`,
Expand Down