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

Using another unique id to identify records #94

Closed
ranzbak opened this issue Oct 11, 2021 · 2 comments
Closed

Using another unique id to identify records #94

ranzbak opened this issue Oct 11, 2021 · 2 comments

Comments

@ranzbak
Copy link

ranzbak commented Oct 11, 2021

tl;dr is it possible to subscribe to objects with another field than the private key?

I'm trying to connect an existing database model to the asynchronous websockets.
I tried the pkField setting in connect, like this:

client = dcrf.connect(`${ws}:${window.location.host}${path}`, {
    pkField: "uuid",
});

But when I try to subscribe to an object I can still only refer to it by the primary key in the table, not uuid.

I would like to use UUID instead of private key in my subscriptions, as UUID are no sequences, and impossible to guess.
Also the rest of the application works with UUID as the unique identifier.

I tried the 'pkField' setting in the configuration block of the connection, but this didn't seem to make any difference.

I'm subscribing with the following code, this fails:

const prom = client.subscribe('user_node', '932895c1-573e-4552-8703-8a9ca9e958ef', (msg, action) => {
    console.log("msg: ", msg, " action: ", action);
}

What does work is the pk, even though pkField is set to 'uuid':

const prom = client.subscribe('user_node', '1', (msg, action) => {
    console.log("msg: ", msg, " action: ", action);
}
@ranzbak
Copy link
Author

ranzbak commented Oct 11, 2021

Wrong project, this needs to go to the Javascript library project.

@ranzbak ranzbak closed this as completed Oct 11, 2021
@hishnash
Copy link
Member

You will need to make some server side changes as well, the deafult subscribtion also assumes PK as the key.

Feel free to re-open this issue so i can track this. It should not be a massive change i thinking you will be able to define on the Consume the field you want to use. Or do you need this to be dynmaic so that differnt clients subscribe based on differnt fields?

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

No branches or pull requests

2 participants