surrealdb / surrealdb.js

SurrealDB SDK for JavaScript
https://surrealdb.com
Apache License 2.0
293 stars 48 forks source link

Feature: Allow for setting the auth token on a per request basis #277

Open LVitus opened 3 months ago

LVitus commented 3 months ago

Is your feature request related to a problem?

I want to use scope users from the backend but creating a new connection instance for every user in the backend uses a lot of resources.

Describe the solution

It would be nice if I was able to pass the token with every request.

db.query('SELECT * FROM user',{}, token)

db.select('user', token)

This way it's possible to use scope users from the backend with the SDK. Right not it is not because all users share the same instance which uses the token which was set last.

Alternative methods

Making requests to the API myself

SurrealDB version

1.5.0 for linux on x86_64

SurrealDB.js version

1.0.0-beta.8

Contact Details

No response

Is there an existing issue for this?

Code of Conduct

mivinci commented 3 months ago

So true!

It'll be so nice and helpful for building a multi-tenant SaaS platform using SurrealDB, because it'll make backends stateless!!

And now that a token is already optionally used when communicating with SurrealDB via HTTP, why not make it work in all SDKs also?