Skip to content

Support params in queries and transactions #950

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

Merged
merged 13 commits into from
Mar 11, 2025
Merged

Support params in queries and transactions #950

merged 13 commits into from
Mar 11, 2025

Conversation

tonsky
Copy link
Contributor

@tonsky tonsky commented Feb 27, 2025

ruleParams let you write permission rules of type “allow access to anyone with a link”. E.g.

{
  docs: {
    view: "ruleParams.secret in data.ref('docLinks.secret')"
  },
  comments: {
    view: "ruleParams.secret in data.ref('parent.docLinks.secret')"
  }
}

Use in queries:

db.useQuery({docs: {}}, { secret: secret })

and transactions:

db.transact(db.tx.docs[id].ruleParams({ secret: secret }).update({ title: 'eat' }));

Updated APIs:

  • db.queryOnce(q, opts?)
  • db.subscribeQuery(q, cb, opts?)
  • db.useQuery(q, opts?)
  • db.tx.ns[id].ruleParams(...).upd...

where opts are { ruleParams: {...}}

Copy link

View Vercel preview at instant-www-js-params-jsv.vercel.app.

@tonsky tonsky force-pushed the params branch 3 times, most recently from 3429e7c to e3d0037 Compare March 6, 2025 16:58
@tonsky tonsky force-pushed the params branch 2 times, most recently from 7a1f6a6 to 88864e1 Compare March 10, 2025 15:13
@tonsky tonsky marked this pull request as ready for review March 10, 2025 16:32
Copy link
Contributor

@stopachka stopachka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! Love the cleanup along the way

@tonsky tonsky force-pushed the params branch 3 times, most recently from 4429af3 to d5e9c44 Compare March 11, 2025 17:58
@tonsky tonsky merged commit dbb7e19 into main Mar 11, 2025
29 checks passed
@tonsky tonsky deleted the params branch March 11, 2025 18:06
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

Successfully merging this pull request may close these issues.

2 participants