datastore-mapper
datastore-mapper copied to clipboard
Passing parameters to "Query"
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
?
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.
it works. I used a private field. It makes sense to document this somehow imho.
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