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

pop EagerPreload or Eager support filter like where #711

Open
inits opened this issue Apr 25, 2022 · 1 comment
Open

pop EagerPreload or Eager support filter like where #711

inits opened this issue Apr 25, 2022 · 1 comment
Labels
f: associations the associations feature in pop s: triage Some tests need to be run to confirm the issue

Comments

@inits
Copy link

inits commented Apr 25, 2022

pop EagerPreload or Eager support filter like where ?

like this

func (v TreesResource) Show(c buffalo.Context) error {
	// Get the DB connection from the context
	tx, ok := c.Value("tx").(*pop.Connection)
	if !ok {
		return fmt.Errorf("no transaction found")
	}

	// Allocate an empty Tree
	tree := &models.Tree{}

	// To find the Tree the parameter tree_id is used.
	if err := tx.EagerPreload("id in (?)", "1","2").Find(tree, c.Param("tree_id")); err != nil {
		return c.Error(http.StatusNotFound, err)
	}

	return responder.Wants("html", func(c buffalo.Context) error {
		c.Set("tree", tree)

		return c.Render(http.StatusOK, r.HTML("trees/show.plush.html"))
	}).Wants("json", func(c buffalo.Context) error {
		return c.Render(200, r.JSON(tree))
	}).Wants("xml", func(c buffalo.Context) error {
		return c.Render(200, r.XML(tree))
	}).Respond(c)
}

@inits
Copy link
Author

inits commented Apr 25, 2022

like this query:

 tx.EagerPreload("id in (?)", "1","2").Find(tree, c.Param("tree_id"))

@sio4 sio4 added s: triage Some tests need to be run to confirm the issue f: associations the associations feature in pop labels Sep 20, 2022
@sio4 sio4 added this to the v6.1.0 milestone Sep 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
f: associations the associations feature in pop s: triage Some tests need to be run to confirm the issue
Projects
None yet
Development

No branches or pull requests

2 participants