Getting a reference to the current user

You currently have two options. You can provide an @default annotation. But, the user can then still change the value of User asked to point to another user:

'User asked': text -> ^ . 'Users'[] @default: user

To prevent that, you currently need a command:

'Submit question': command { 'ID': text } => switch user (
    | node as $'user' => update .'Questions' = create (
        'Question id' = @ .'ID'
        'User asked' = $'user'.'Name'
    )
    | none => ignore // question was not submitted by a signed-in user (but by a system)
)

We plan to support a solution that does not require a command as well.

1 Like