Given this create user if not exist query:
Let(
{
match: Match(Index('users_by_email'), 'foo@bar.biz'),
data: { email: 'foo@bar.biz' },
password: 'foobar',
},
If(
Exists(Var('match')),
{
type: 'createUser',
data: { message: 'User already exists' },
},
Create(Collection('Users'), {
data: Var('data'),
credentials: { password: Var('password') },
}),
),
)
If the user exists, it will return:
{ type: 'createUser', data: { message: 'User already exists' } }
If not, it will create it and come back with:
{
ref: Ref(Collection("Users"), "327348265972400640"),
ts: 1648442483850000,
data: { email: 'foo@bar.biz' }
}
How I can tap into Create
return value? After creating the user I would like to return something like:
{
type: 'createUser',
data: {
email: 'foo@bar.biz',
id: '327348265972400640'
}
}