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

Extension of already existing plugins #178

Open
hunte-star opened this issue Jan 25, 2022 · 4 comments
Open

Extension of already existing plugins #178

hunte-star opened this issue Jan 25, 2022 · 4 comments

Comments

@hunte-star
Copy link

The balance plugin already creates a db table but the api just takes row and page parameter in request body. Now if I need to extend this plugins' already existing feature by adding account search how do I go about it. I tried adding a new route within the balance plugin https://github.com/itering/subscan-essentials/blob/master/plugins/balance/http/http.go#L18 but data is not being queried through and modification in one route's function affected the other.

@freehere107
Copy link
Collaborator

You just need to add a new route to https://github.com/itering/subscan-essentials/blob/65a62200b6277ff02d38d50bc0658cc2df3aa16c/plugins/balance/http/http.go#L20 and write the query in this handle logic

@hunte-star
Copy link
Author

Yeah i tried that and wrote a query similar to this https://github.com/itering/subscan-essentials/blob/master/plugins/system/dao/dao.go#L24
db.FindBy(&accountser, map[string]interface{}{"address": address}, nil) but the data it returns is nil and due to this the other account route also returns empty json when invoked.
Is the query in the above FindBy method correct or am i missing something?

@hunte-star
Copy link
Author

[Update] Both routes work separately when the other is commented out but when both are present data is not returned properly.

return []router.Http{
{"accounts", accounts},
//{"findac", findac},
}

The accounts route returns multiple db table rows while findac return only one.

@andropixels
Copy link

you can achieve this by using query parameters

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

3 participants