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

Find resources unique field that is not the primary key? #34

Open
ranzbak opened this issue Oct 11, 2021 · 0 comments
Open

Find resources unique field that is not the primary key? #34

ranzbak opened this issue Oct 11, 2021 · 0 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);
}
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

1 participant