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

Passing parameters to "Query" #29

Open
tim-lebedkov opened this issue Mar 27, 2017 · 3 comments
Open

Passing parameters to "Query" #29

tim-lebedkov opened this issue Mar 27, 2017 · 3 comments

Comments

@tim-lebedkov
Copy link

I created a job that should transform entities from one kind to another by getting the values from the request:

`func (x *transform) Query(r *http.Request) (*mapper.Query, error) {
c := appengine.NewContext(r)

err := r.ParseForm()
if err != nil {
	return nil, err
}

from := r.Form.Get("from")
to := r.Form.Get("to")

q := mapper.NewQuery(from)
q = q.NamespaceEmpty()
return q, nil

}
`

How can I pass this value ("to") to
func (x *transform) Next(c context.Context, counters mapper.Counters, key *datastore.Key) error
?

@CaptainCodeman
Copy link
Owner

CaptainCodeman commented Mar 27, 2017

I need to check but I think I made it so the struct is encoded and stored in the datastore so it should be possible to set values on it and then see them in the later stages, as long as they are public / exported and the struct is gob encodable.

@tim-lebedkov
Copy link
Author

it works. I used a private field. It makes sense to document this somehow imho.

@CaptainCodeman
Copy link
Owner

CaptainCodeman commented Mar 28, 2017

Yes definitely, I don't think I ever ended up needing to use it myself so kind of forgot about it :)

Probably makes sense to add something to one of the examples

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

2 participants