I need some help with a FaunaDB function.
I have the following register function to register a User:
Query(
Lambda(
["email", "username", "password"],
Create(Collection("User"), {
credentials: { password: Var("password") },
data: { email: Var("email"), username: Var("username") }
})
)
)
It works fine and returns the following output:
{
ref: Ref(Ref("tokens"), "220428023135601160"),
ts: 1603695853275000,
ttl: Time("2020-10-26T10:04:12.646314Z"),
instance: Ref(Collection("User"), "220412125733585420"),
secret: "SECRET_STRING"
}
I want to change the function so that it returns the User Data according to the Ref of the instance variable Get(Var("instance"))
and the secret
string.
So that it looks similar to this:
{
secret: "SECRET_STRING",
user: {
... //user data
}
}
I am tried to apply several functions but did not get it to work...
Something like that might work for you?
Luigi