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

First-class-ish support for slugs #952

Open
stephenh opened this issue Jan 22, 2024 · 0 comments
Open

First-class-ish support for slugs #952

stephenh opened this issue Jan 22, 2024 · 0 comments

Comments

@stephenh
Copy link
Collaborator

Slugs in URLs are similar to tagged ids, but incorporate part of the entity's data directly, i.e. Author firstName=bob might have an Author slug=bob-123, which looks tagged-ish, but isn't actually immutable (users can change the firstname, username, etc).

There are Rails gems that incorporate slugs into ActiveRecord, i.e. friendly_ids, so it'd be interesting to see if we could do something similar with Joist.

This would very likely just be a use case that was supported by a plugin, and not a core feature, but one could imagine a query rewriting plugin that would:

  • See a where = { author: "someString" } clause for an em.find/etc
  • Pattern match the some string has "probably/definitely a slug
  • Rewrite the query AST to be where = { author: { slugs: { slug: "someString" } } }, i.e. a join into the slugs table that keeps track of the 1-N slugs that have been created for the given Author

If we were super-fancy, the domain.id might start returning slugs, which at least for Joist would be fine because we've moved basically all of the internals over to idTagged to support maybe/maybe-not tagged ids.

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

No branches or pull requests

1 participant