Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

Use auto generated id variable in optimistic response rather than Client:xxxxx #75

Closed
Hasan-git opened this issue Jun 29, 2019 · 4 comments
Milestone

Comments

@Hasan-git
Copy link

Is it possible to use the variable id (which is auto-generated on client-side) in optimistic response rather than "client:xxxxxx".

In case of nested data, this approach will cause an issues. Then, my solution is always to generate an id on client side and offix should accept this variable.

image

@wtrocki
Copy link
Contributor

wtrocki commented Jul 1, 2019

I love this idea! Really really useful feedback.
We needed to have a unified way to know if the id we dealing with is autogenerated.
We execute id mapping after based on that.

Does having client:Greeting:xxxxxx will resolve this problem?
If yes then this is very trivial fix. In fact, we do not need function initially to satisfy this requirement - we have access to typename so our id should be:

client:{TypeName}:{generatedId}

From my side this should be done like this from the first place, but at the time we wrote it we did not had typeName information inside the core.

WDYT?

@Hasan-git
Copy link
Author

Does having client:Greeting:xxxxxx will resolve this problem?

Of course no, greeing.id should be the id set by variables.id ,,, this fixes the issue

Reproduce

Assume that we have the below scenario (it's a real scenario) .

STEP 1 create a location while offline:

      location: {
        id: "client:0dh0M5MW",
        name: "Saint George",
        contact: ""
      }

STEP 2 creating a condition while offline

      condition: {
        id: "WHAT EVER",
        location: {
          id: "client:0dh0M5MW", //  <--- relation, the server expects GUID or ObjectId.... throw an error
          name: "Saint George",
        },
        medications: [],
        opened: "2019-05-09"
        .....
      }

Currently, I'm using mongodb which uses ObjectId as default primary key.... .
The idea , when creating any new item I'am always providing item id (ObjectId) on client side, then I'm able to use items freely while offline and when going online the server will save the data with there generated ids (by client).

So, I'm expecting item object should be stored as =>

Location:5d19ebc00bc49edf8ffad966 {
    id : "5d19ebc00bc49edf8ffad966 ",  < --- 
    name: "Saint George"
}

id is equivalent to variables.id

rather than

Client:XdhXM5XX {
    id : "Client:XdhXM5XX ", <---
    name: "Saint George"
}

@wtrocki
Copy link
Contributor

wtrocki commented Jul 1, 2019

Awesome.

Of course no, greeing.id should be the id set by variables.id ,,, this fixes the issue

Yes. Now I fully understand what we mean here. Yes. We should resolve this problem

@wtrocki
Copy link
Contributor

wtrocki commented Jun 4, 2020

Passing Id is now possible thru the client (both by data or using your own optimistic response creator. Thank you for logging issue

@wtrocki wtrocki closed this as completed Jun 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants