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

More query condition delegations? #222

Open
oxf71 opened this issue Sep 27, 2024 · 0 comments
Open

More query condition delegations? #222

oxf71 opened this issue Sep 27, 2024 · 0 comments

Comments

@oxf71
Copy link

oxf71 commented Sep 27, 2024

I have studied the structure of the delegations table. I can use SQL queries to retrieve the data I need, such as querying all stakers under finality_provider_pk_hex. Add more query conditions at the API ?

query fields:

  1. stake_tx.start_height
  2. state
  3. is_overflow
  4. finality_provider_pk_hex

sort fields:

  1. stake_tx.start_height

example find:

from pymongo import MongoClient

# Requires the PyMongo package.
# https://api.mongodb.com/python/current

client = MongoClient('mongodb://admin:admin@localhost:27017/?directConnection=true')
filter={
    'staking_tx.start_height': 857910
}

result = client['staking-api-service']['delegations'].find(
  filter=filter
)
from pymongo import MongoClient

# Requires the PyMongo package.
# https://api.mongodb.com/python/current

client = MongoClient('mongodb://admin:admin@localhost:27017/?directConnection=true')
filter={
    'finality_provider_pk_hex': '2f8ec74d558fe7a97d10be230bf1485db9be675228abfbf957ba050c714b679a', 
    'state': 'active', 
    'is_overflow': False
}
sort=list({
    'staking_tx.start_height': -1
}.items())

result = client['staking-api-service']['delegations'].find(
  filter=filter,
  sort=sort
)
from pymongo import MongoClient

# Requires the PyMongo package.
# https://api.mongodb.com/python/current

client = MongoClient('mongodb://admin:admin@localhost:27017/?directConnection=true')
filter={
    'finality_provider_pk_hex': '2f8ec74d558fe7a97d10be230bf1485db9be675228abfbf957ba050c714b679a', 
    'state': 'active', 
    'is_overflow': False,
'staking_tx.start_height': 857910
}

result = client['staking-api-service']['delegations'].find(
  filter=filter
)
@oxf71 oxf71 changed the title add more query criteria to the delegations table? more query criteria to the delegations table? Sep 27, 2024
@oxf71 oxf71 changed the title more query criteria to the delegations table? More query condition delegations? Sep 27, 2024
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