Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

oldKeys field is not supported, right? #31

Open
scythargon opened this issue May 5, 2024 · 4 comments
Open

oldKeys field is not supported, right? #31

scythargon opened this issue May 5, 2024 · 4 comments

Comments

@scythargon
Copy link

Hi! First of all - thank you for you library! It's great!

But currently when used with wal2json - it does not allow to determine which row was deleted or updated, right?

Because oldKeys is not present in the lib source, I believe.

Here it is in wal2json readme:

85737

Do you have plans to add it? Or will you be fine if I submit a MR?

Thank you again.

@kibae
Copy link
Owner

kibae commented May 6, 2024

Hi, @scythargon :)
Because the data transmitted from the server is passed through without modification, the oldKeys field is included in the response. However, it is missing from the TypeScript interface, which I will update soon.

image

@kibae
Copy link
Owner

kibae commented May 6, 2024

@scythargon
I've published version 2.0.6 of the npm package with only minor changes. Unfortunately, I was not able to define the type as a union type based on the values of Change.kind('insert' | 'update' | 'delete' | 'message' | 'truncate'). If you're interested, I would appreciate your contribution. :)

https://www.npmjs.com/package/pg-logical-replication

@scythargon
Copy link
Author

Hey! Thanks!:) I didn't get what you mean by the type issue, could you elaborate please?

@kibae
Copy link
Owner

kibae commented May 7, 2024

export interface Change {
kind: 'insert' | 'update' | 'delete' | 'message' | 'truncate';
schema: string;

In TypeScript, there is a feature called union type. You can define a type such that the oldKeys value exists only when the kind of Change is either 'update' or 'delete', based on the value of kind.

https://www.typescriptlang.org/docs/handbook/unions-and-intersections.html#discriminating-unions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants