Hi,
Not sure if this is a bug.
I’m trying to get the error value to show with an If statement when a user exists, but I get an undefined.
Email elready exists in collection users.
This returns an undefined when called:
Query(
Lambda(
["email", "password", "userName"],
Let(
{
exists: Exists(Match(Index("usersByEmail"), Var("email"))),
user: If(
Not(Var("exists")),
Create(Collection("users"), {
credentials: { password: Var("password") },
data: { email: Var("email"), userName: Var("userName") }
}),
"user already exists"
)
},
{ user: Var("user"), error: If(Var("exists"), "user exists", null) }
)
)
)
returns:
undefined
Though this works strangely, if the string is empty on the If expression.
Query(
Lambda(
["email", "password", "userName"],
Let(
{
exists: Exists(Match(Index("usersByEmail"), Var("email"))),
user: If(
Not(Var("exists")),
Create(Collection("users"), {
credentials: { password: Var("password") },
data: { email: Var("email"), userName: Var("userName") }
}),
"user already exists"
)
},
{ user: Var("user"), error: If(Var("exists"), "", null) }
)
)
)
returns:
{
user: "user already exists",
error: ""
}
Any help is appreciated.