Skip to content

Nested query for YAML based TinyDB table #554

Answered by msiemens
TheNewThinkTank asked this question in Q&A
Discussion options

You must be logged in to vote

I guess you're using the YAMLStorage from https://tinydb.readthedocs.io/en/latest/extend.html?

In general, TinyDB is not particularly strong when searching a dict for an entry with a particular value. Query.any for example will run on a dict's keys, not values. If you store your exercises as a list, you can easily find an entry with weight containing BODYWEIGHT:

weight_training_log:
  '188':
    date: '2024-01-07'
    start_time: '15:50'
    end_time: '16:22'
    timezone: CET
    split: push
    exercises:
      - type: incline_db_press
        sets:
        - set_number: 1
          reps: 8
          weight: 40 kg
        - set_number: 2
          reps: 10
          weight: 40 kg

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by TheNewThinkTank
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants