-
Notifications
You must be signed in to change notification settings - Fork 114
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
Better control and allow inclusion of the _etag field #164
Comments
@Dragomir-Ivanov , @rs - to continue the discussion here. We have discussed two options previously:
1 is maybe what gives me the best feeling; you are planning to update an (embedded) or list item, and you ask for at least the "id" and the "_etag" field. Also it's included as a field, so why not ask for it as a field? However, I have until now assumed that 1 is maybe hard to implement. If we talk implementation, I have a plausible way forward for 1, but we need to add one more feature to make it work: we need to allow incllusion of hidden fields (and maybe add a new |
Writing on my phone so wikl correct the grammar later... |
I'm all for 1., moving the _tag in the payload and using a hidden/secret/whatever field type to make it not part of the default payload. |
This should govern inclusion the |
Some code links. Allow hidden fields to be included (could be first PR)Probably around here...
To allow the original use-case of Allow
|
func (r *Resource) Bind(name, field string, s schema.Schema, h Storer, c Conf) *Resource { |
We need to do the same in new
called by resource.index.Bind()
. Note that the new
function overrides the built-in Go new
function which is a bit confusing -- feel free to rename new
to newResource
for better readability PS! resource.New
would have been find for a public function, but this is private.
Line 49 in 3ffe90e
func (i *index) Bind(name string, s schema.Schema, h Storer, c Conf) *Resource { |
rest-layer/resource/resource.go
Line 78 in 3ffe90e
fallback: schema.Schema{Fields: schema.Fields{}}, |
There probably also need to be some more changes to actually put the E-tag into the item
payload before schema/query
applies the projection....
I think that Currently The new Your comments appreciated. |
Some minor points.
Agree, but I think it is still good enough. We can have another look at
This should be decided by the existing |
Maybe a better name then |
Another option could be to replace the ReadOnly field with an enum: type FieldMode
const (
ModeReadWrite = iota
ModeReadOnly
ModeWriteOnly
ModeNoAcces
) |
@smyrman I actually like the last idea about the
By default fields can have @rs Your input appreciated. |
Either way works for me. My preference would go for @smyrman's version as it is more expressive. |
Yeah, I thought about that. However, since it's Go, one extra consideration to have in mind is that all types have default zero values. Therefore, if you can get away with make the default case a zero value, the code get's signifincantly less complex as no struct initialization method is needed. If you flip your proposal, and we have const(
ModeReadWrite = 0x00
ModeReadOnly = 0x01 // same as ModeNoWrite
ModeWriteOnly = 0x02 // same as ModeNoRead
ModeNoAcces = 0x03 // same as ModeNoWrite | ModeNoRead
How so? Are we no planning to "redefine" hidden to mean weather or not a field is hidden from the response by default? Won't we still need a field for that? We could of-course define a bitmask for that as well, but the main goal off the schema should probably be to optimize for the best expressiveness. |
Otherwise it was a good proposal @Dragomir-Ivanov. |
@smyrman Yes, that makes sense. I was mistaken, this work will not depreciate |
As discussed in #157, there should be a consistent way to control and include _etag in embedded items as well as root items in all
GET
views.The text was updated successfully, but these errors were encountered: