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

Add Patch #7

Open
ashtonian opened this issue Sep 9, 2020 · 4 comments
Open

Add Patch #7

ashtonian opened this issue Sep 9, 2020 · 4 comments

Comments

@ashtonian
Copy link
Collaborator

Proper patch, multi resource, support multiple resources same query. diff between null, undefined, and "" or 0.

@ashtonian
Copy link
Collaborator Author

example body:

[
{
   "op":"test",
   "path":"/a/b/c",
   "value":"foo"
 },
 {
   "op":"remove",
   "path":"/a/b/c"
 },
 {
   "op":"add",
   "path":"/a/b/c",
   "value":[
     "foo",
     "bar"
   ]
 },
 {
   "op":"replace",
   "path":"/a/b/c",
   "value":42
 },
 {
   "op":"move",
   "from":"/a/b/c",
   "path":"/a/b/d"
 },
 {
   "op":"copy",
   "from":"/a/b/d",
   "path":"/a/b/e"
 }
]

limit to replace (+ maybe remove) implementation initially.

Ideal:
ParseFields, verify name, verify type, verify op is allowed.

@ashtonian
Copy link
Collaborator Author

ashtonian commented Sep 20, 2020

Patchy:

type Op struct {
Operation string 
From string 
Path String 
Value interface{}
}

// created using reflection once, then used every query to generate sql. 
type PatchSpec struct {
TargetResource string 
Fields  []PatchField
}

type PatchField struct {
AllowedOps string
TargetType string
Validator func // only need two funcs
Converter func
Filter func
}

func (op *Op) GetValue() interface{} {
} 

type Error struct {
Attempted Op
Reason string 
Code int // custom 
}

allow 201 status code with soft rejections. SQL util to generate sql statement from []OP.

@ashtonian
Copy link
Collaborator Author

@ashtonian
Copy link
Collaborator Author

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