adamjkb / bark

Materialized path extension for Prisma
https://prisma-extension-bark.gitbook.io
MIT License
33 stars 5 forks source link

Helper functions #27

Open adamjkb opened 1 year ago

adamjkb commented 1 year ago

A collection of syntactic sugar functions to help make repetitive task easier. A couple of examples of what these might be called:

The collection could also expose internal utility functions we are already using inside of the extension:

kran6a commented 4 months ago

I would also add a findLowestCommonAncestor method. LCA is a very common operation on graphs and the whole tree spanning from the LCA to the leaves (returned by findAncestors) might not be needed or might be so large it has a noticeable impact in performance.

Nedi11 commented 1 month ago

I would like to add a findLeafs helper

adamjkb commented 1 month ago

I would like to add a findLeafs helper

Could you expand on that? Would that be different to what findDescendants is doing?

Nedi11 commented 1 month ago

I would like to add a findLeafs helper

Could you expand on that? Would that be different to what findDescendants is doing?

e.x: lvl1->lvl2.1->lvl3.1 |->lvl2.2->lvl3.2 findDescendants gets all descendants. findDescendants on lvl1 would return lvl2.1 and lvl2.2 also if I am not mistaken (as well as lvl3). findLeafs would only return lvl3.1 and lvl3.2

**leaves is the correct plural of leaf so findLeaves I guess🙂

adamjkb commented 1 month ago

I would like to add a findLeafs helper

Could you expand on that? Would that be different to what findDescendants is doing?

e.x: lvl1->lvl2.1->lvl3.1 |->lvl2.2->lvl3.2 findDescendants gets all descendants. findDescendants on lvl1 would return lvl2.1 and lvl2.2 also if I am not mistaken (as well as lvl3). findLeafs would only return lvl3.1 and lvl3.2

**leaves is the correct plural of leaf so findLeaves I guess🙂

Ah yes, thank you! I get it now. I'll add it to the list, although ideally it should be possible to do if the results can filtered. (Currently not the case but it would be nicer if you could just filter leaves while querying the database)