There are a few places we could automatically set the userId context.
Its important to note that the authorization for that user will always be set in the API (so you can pass null userIds to nile-auth and it will still work, just look bad)
I think this is more about what would happen in a scenario like
await nile.auth.signIn({email, password});
await nile.db.query('select * from todos');
I believe the intent is to have this work (right now you have to set the userId, at least), but I think it will also be confusing because if you need to list all of the todos, you have need set nile.userId = null before you could do that.
What should the default behavior be? I think in either direction, you're going to have a lot of unsetting or re-setting, depending on the app.
My gut tells me since we are "tenant aware OOTB", and we decided that we won't default users to specific tenants, because that would be unexpected, we should follow that here, eg you must "opt in" to the db side of nile.user_id, and we should not do it for you.
Happy to discuss here, since it will be good to document the decision where it affects the implementation
There are a few places we could automatically set the userId context.
Its important to note that the authorization for that user will always be set in the API (so you can pass null userIds to nile-auth and it will still work, just look bad)
I think this is more about what would happen in a scenario like
I believe the intent is to have this work (right now you have to set the userId, at least), but I think it will also be confusing because if you need to list all of the todos, you have need set
nile.userId = nullbefore you could do that.What should the default behavior be? I think in either direction, you're going to have a lot of unsetting or re-setting, depending on the app.
My gut tells me since we are "tenant aware OOTB", and we decided that we won't default users to specific tenants, because that would be unexpected, we should follow that here, eg you must "opt in" to the db side of
nile.user_id, and we should not do it for you.Happy to discuss here, since it will be good to document the decision where it affects the implementation