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

globs: "exists" filter #1567

Closed
alixander opened this issue Aug 25, 2023 · 6 comments · Fixed by #2009
Closed

globs: "exists" filter #1567

alixander opened this issue Aug 25, 2023 · 6 comments · Fixed by #2009

Comments

@alixander
Copy link
Collaborator

e.g. target all shapes that have links, or all connections that have labels.

not sure how it'll be represented in the syntax

@cyborg-ts cyborg-ts added this to D2 Aug 25, 2023
@alixander
Copy link
Collaborator Author

oh this can just use globs within.

this would filter for existence of link

*: {
  &link: *
}

i think we need a "not" operator too. maybe !? not sure. @nhooyr any thoughts?

*: {
  !&link: *
}

@asanjabi
Copy link

! seems like a reasonable symbol for "not" operator. What would the syntax look like for nulling all shapes that don't have a connection? (** !-> *)[*]: null ?

@alixander
Copy link
Collaborator Author

we'd just introduce a keyword for that. something like

*: null {
  &connected: false
}

@nhooyr
Copy link
Contributor

nhooyr commented Aug 25, 2023

Seems reasonable to have !& to me.

nhooyr added a commit to nhooyr/d2 that referenced this issue Aug 30, 2023
nhooyr added a commit to nhooyr/d2 that referenced this issue Aug 30, 2023
@terrastruct terrastruct deleted a comment from XoL1507 Sep 4, 2023
@gavin-ts
Copy link
Contributor

Regarding globs for selecting all existing edges:

I tried * -> * but this creates edges between all shapes and does not apply to existing edges, interestingly (* -> *)[*] does apply only to existing edges.

I think https://d2lang.com/tour/globs#glob-connections needs a note to clarify that the parens + brackets syntax is needed to select existing edges(* -> *)[*]. It is present in the example but a explicit note would make it clear.

Screenshot 2023-09-21 at 11 10 57 AM

https://play.d2lang.com/?l=&script=ys9LtVKo5lJQSFTQtVNIAhHJICKFi0tBQQvE0oLIKyiAbdWDuMNKoSg1hUtBoZarlourpDwftxkaEEM0o7ViCRkECAAA__8%3D&

This was referenced Jul 18, 2024
@alixander
Copy link
Collaborator Author

alixander commented Jul 18, 2024

#1567 (comment) will be tracked in #2010

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants