I have somewhat what seems to be a fairly simple question.
Lets assume we are building a Todo list where everything is public. And lets say a user will be able to create a new Task and that task will have subtasks.
So, For the tasks I can create an account to store all the tasks with the follwing seeds.
pub struct Task {
pub id: u64;
pub count: u32; // This is important to keep track of the count of sub tasks on a task
}
This will allow me to create a task account with seed [TASK, task.id, &[bump]]
where TASK is const TASK = b"task"
. And
pub struct SubTask {
pub task_id: u64;
pub id: u64;
}
Gives me subtask with seeds [SUBTASK, task.id, sub_task.id, &[bump]]
. So this allows me to fetch, all the tasks and the subtasks related to a specific task.
But I was curious, how would I improve this so that I can also fetch all the tasks/sub tasks related to a user irrelevant of market. i.e. give me all the sub tasks an account with pubkey has created.
Thank you.