Open EtienneBruines opened 1 week ago
Not only this, but also I just realized I've been using the wrong methods (making me wander why my own project with SurrealDB 1.5.4 is even working).
This requires quite some work compared to the other issue, thanks for reporting it 🙏
That might explain the generated surreal-ws.d.ts
file saying that (almost) all functions return boolean
and not boolean | any
.
That might explain the generated
surreal-ws.d.ts
file saying that (almost) all functions returnboolean
and notboolean | any
.
Oh, about this: no they are supposed to only return booleans. If you need to access the actual information you have to access data
to do so.
In the your provided snipped you should do something like (although, still not ideal):
const { data, signin } = useSurrealWS()
const result = await signin({ /* auth data */})
if (result) {
console.trace(data.value)
}
This is one of the reasons why I suggest to use signin
operations outside/before creating a ws connection.
data
will update whenever SurrealDB has to inform you about something you have executed or subscribed at (like with a live('table_name')
), but I currently don't inform which id is about which data return.
I can already see me rewrite useSurrealWS
from scratch...
Workflow:
Currently, the
isReady.auth
value insurreal-ws.js
stays atfalse
because a successfulsignin
is never parsed (since id=1 is hardcoded and id=1 is never used to send thesignin
request).This causes all queries (including
signin
) to returnfalse
. It does run the_init()
function every time, but the_init()
function does not correctly login either. It sends a potentialuserToken
(fromuseSurrealAuth
) or anoptions.auth
- but never does it use anything related to thesignin
function.Perhaps it makes sense to overwrite the
authId
when sending thesignin
request, or use theauthId
when sending thesignin
request instead of the auto-incremented message id?This does not seem to be version-related, but for sake of completness: SurrealDB version v2.0.4 and nuxt-surrealdb version v0.3.4