Skip to content
This repository has been archived by the owner on Aug 2, 2019. It is now read-only.

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

Open
Natim opened this issue Nov 28, 2014 · 6 comments

Comments

@Natim
Copy link
Member

Natim commented Nov 28, 2014

No description provided.

@Natim Natim changed the title Let's define a model field as primaryKey that will be used on the POST /records and validate with the recordId on PUT Let's define a model field as primaryKey that will be used on the POST /records and validated with the recordId on PUT Nov 28, 2014
@leplatrem
Copy link
Contributor

Do you mean oneof ?

@almet
Copy link
Member

almet commented Dec 5, 2014

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.

@leplatrem
Copy link
Contributor

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

@almet
Copy link
Member

almet commented Dec 5, 2014

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/alexis@notmyidea.org was actually submitted by a verified account.

@leplatrem
Copy link
Contributor

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 ?

@Natim
Copy link
Member Author

Natim commented Dec 22, 2014

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.

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

No branches or pull requests

3 participants