daybed icon indicating copy to clipboard operation
daybed copied to clipboard

Let's define a model field as primaryKey that will be used on the POST /records and validated with the recordId on PUT

Open Natim opened this issue 10 years ago • 6 comments
trafficstars

Natim avatar Nov 28 '14 13:11 Natim

Do you mean oneof ?

leplatrem avatar Nov 28 '14 13:11 leplatrem

Yeah, the title is not really self-explanatory.

What (I understood) we want here is a way to actually have a field of the data filled from data that's externally provided. For instance, we could have a field which matches the hawk id we're using, or have a field which is filled using the name of the model.

almet avatar Dec 05 '14 07:12 almet

Okay, I believe I understood... Something like that :

{  name: "creator",
   type: "autofill",
   value: "CREDENTIALS_ID" }

With some constants like MODELNAME etc.

Well... I would have relied on the client to do that, but since I guess it should not be forged we have to do something server-side.

I still would like to see an explicit use-case to judge if the solution is relevant. For example, it can slightly be related to #222

leplatrem avatar Dec 05 '14 08:12 leplatrem

Actually we have two different things: the first one, the "autofill" type, which is useful when we want to associate a creator to a record, as you shown (for instance), and we also need a way to have the server check for us that the id of a record matches a specific notion (for instance the hawkid, or the firefox accounts email).

So that we are sure that /v1/models/keys/records/[email protected] was actually submitted by a verified account.

almet avatar Dec 05 '14 08:12 almet

Ideally, it should have several obvious use-cases (the creator isn't one, since we can have #222). And from what you describe, I don't see it very generic and reusable :( Maybe should it be thought as a plugin ?

leplatrem avatar Dec 05 '14 09:12 leplatrem

No that's not what I was talking about.

The idea is more having a field that IS the record primary key.

{  name: "slug",
   type: "string",
   primary: true
}

Then if I do a POST with:

{slug: "toto"}

It will answer:

{id: "toto"}

Also it will fail to validate if I do a PUT on /records/something if this something isn't toto.

Natim avatar Dec 22 '14 10:12 Natim