Skip to content

Sync breaks when transforming created_at and modified_at fields #623

@AlexanderBadak

Description

@AlexanderBadak

When using the configuration

configureSyncedSupabase({
	changesSince: 'last-sync',
	fieldCreatedAt: 'created_at',
	fieldUpdatedAt: 'modified_at',
	fieldDeleted: 'deleted',
	updatePartial: true
})

const store$ = observable(
	syncedSupabase({
		supabase,
		collection: 'store',
		filter: select => select.eq('user_id', '1'),
		transform: {
			load(value) {
				return {...value, modifiedAt: value.modified_at}
			},
			save(value) {
				return {...value, modified_at: value.modifiedAt}
			}
		},
		persist: {
			plugin: ObservablePersistLocalStorage,
			name: 'store',
			retrySync: true
		}
	})
)

The plugin tries to POST instead of PATCH the first time you update a value. If I leave the fields untransformed it works just fine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions