Fork me on GitHub

Hey guys if I have my client state as

{ :list/id {:accounts { :list/accounts [ [:account/id 1] [:account/id 2] ....] } } }
I was trying to query for it w/ the following:
(db->tree [{:list/id [:accounts]}] {} (current-state SPA))
I'm getting {} returned, I was wondering what would be the appropriate query to retrieve the list of accounts


[{[:list/id :accounts] [{:list/accounts [*]}]}]


On a phone .. hard to input those


thank you, I think I should not nest it so much.


@alexander.890 (db->tree [{[:list/id :accounts] [{:list/accounts [*]}]}] (current-state SPA) (current-state SPA)) This should solve your question. The second arg to db->tree is the starting-entity which should not be an empty map. In most cases, querying from the root, you can use state-map i.e. (current-state SPA) as the starting-entity as well. Using the query shown by Tony, you use join to "drill down" into the subquery, where [*] is determined by your data design, for example [:account/name :account/status].

❤️ 3

Thank you


I'll keep in mind to use current-state for the starting-entity


Just read Tony's new chapter on Core API and learnt something new. Turns out @U0CKQ19AQ has already given you the full answer. By using ident [:list/id :account] as a query element, you can indeed put an empty map as the starting-entity because the ident already provides the starting-entity. So, this works too: (db->tree [{[:list/id :accounts] [{:list/accounts [*]}]}] {} (current-state SPA))


P.S. There are many ways to make this work. Long story short, check out Tony's new chapter, especially the section on denormalization:


So, I’ve added a new chapter, targeted at semi-beginners, to the book:

❤️ 6

It encourages you to explore the core API of Fulcro with a simple CLJ REPL, and I hope it will help beginners gain an understanding of the very simple concepts at the center of Fulcro.


I know there’s a lot of material out there, and I keep trying to find a way to narrow people’s focus on what is truly core to understanding Fulcro. This chapter is my attempt at that.

👏 39
🙌 9
👍 9

The new chapter is more than helpful. Full of gems, simply outstanding. Many thanks @U0CKQ19AQ for sharing your knowledge and wisdom with us.