@@ -78,7 +78,7 @@ export function useSurrealDB(overrides?: Overrides) {
78
78
thing : MROGParam < T , 'create' , 0 > ,
79
79
data ?: MROGParam < T , 'create' , 1 > ,
80
80
options ?: UseSurrealRpcOptions < T > ,
81
- ) : Promise < AsyncData < PickFrom < T , KeysOf < T > > | null , FetchError < any > | RpcResponseError | null > > {
81
+ ) : Promise < AsyncData < PickFrom < T , KeysOf < T > > | undefined , FetchError < any > | RpcResponseError | null > > {
82
82
const { database, immediate, key, token, watch, ...opts } = options || { }
83
83
84
84
const params = computed < RpcRequest < T , 'create' > [ 'params' ] > ( ( ) => ( [ toValue ( thing ) , toValue ( data ) ] ) )
@@ -107,7 +107,7 @@ export function useSurrealDB(overrides?: Overrides) {
107
107
}
108
108
async function info < T = any > (
109
109
options ?: UseSurrealRpcOptions < T > ,
110
- ) : Promise < AsyncData < PickFrom < T , KeysOf < T > > | null , FetchError < any > | RpcResponseError | null > > {
110
+ ) : Promise < AsyncData < PickFrom < T , KeysOf < T > > | undefined , FetchError < any > | RpcResponseError | null > > {
111
111
const { database, key, token, ...opts } = options || { }
112
112
113
113
const _key = key ?? 'Sur_' + hash ( [ 'surreal' , 'info' ] )
@@ -137,7 +137,7 @@ export function useSurrealDB(overrides?: Overrides) {
137
137
thing : MROGParam < T , 'insert' , 0 > ,
138
138
data ?: MROGParam < T , 'insert' , 1 > ,
139
139
options ?: UseSurrealRpcOptions < T > ,
140
- ) : Promise < AsyncData < PickFrom < T , KeysOf < T > > | null , FetchError < any > | RpcResponseError | null > > {
140
+ ) : Promise < AsyncData < PickFrom < T , KeysOf < T > > | undefined , FetchError < any > | RpcResponseError | null > > {
141
141
const { database, immediate, key, token, watch, ...opts } = options || { }
142
142
143
143
const params = computed < RpcRequest < T , 'insert' > [ 'params' ] > ( ( ) => ( [ toValue ( thing ) , toValue ( data ) ] ) )
@@ -198,7 +198,7 @@ export function useSurrealDB(overrides?: Overrides) {
198
198
thing : MROGParam < T , 'merge' , 0 > ,
199
199
data : MROGParam < T , 'merge' , 1 > ,
200
200
options ?: UseSurrealRpcOptions < T > ,
201
- ) : Promise < AsyncData < PickFrom < T , KeysOf < T > > | null , FetchError < any > | RpcResponseError | null > > {
201
+ ) : Promise < AsyncData < PickFrom < T , KeysOf < T > > | undefined , FetchError < any > | RpcResponseError | null > > {
202
202
const { database, immediate, key, token, watch, ...opts } = options || { }
203
203
204
204
const params = computed < RpcRequest < T , 'merge' > [ 'params' ] > ( ( ) => ( [ toValue ( thing ) , toValue ( data ) ] ) )
@@ -233,7 +233,7 @@ export function useSurrealDB(overrides?: Overrides) {
233
233
patches : MROGParam < T , 'patch' , 1 > ,
234
234
diff ?: MROGParam < T , 'patch' , 2 > ,
235
235
options ?: UseSurrealRpcOptions < T > ,
236
- ) : Promise < AsyncData < PickFrom < T , KeysOf < T > > | null , FetchError < any > | RpcResponseError | null > > {
236
+ ) : Promise < AsyncData < PickFrom < T , KeysOf < T > > | undefined , FetchError < any > | RpcResponseError | null > > {
237
237
const { database, immediate, key, token, watch, ...opts } = options || { }
238
238
239
239
const params = computed < RpcRequest < T , 'patch' > [ 'params' ] > ( ( ) => ( [ toValue ( thing ) , toValue ( patches ) , toValue ( diff ) ] ) )
@@ -262,17 +262,17 @@ export function useSurrealDB(overrides?: Overrides) {
262
262
token : options ?. token || overrides ?. token ,
263
263
} )
264
264
}
265
- async function query < T = any , R = QueryRpcResponse < T > > (
265
+ async function query < T = any [ ] > (
266
266
sql : MROGParam < any , 'query' , 0 > ,
267
267
vars ?: MROGParam < any , 'query' , 1 > ,
268
- options ?: UseSurrealRpcOptions < R > ,
269
- ) : Promise < AsyncData < PickFrom < R , KeysOf < R > > | null , FetchError < any > | RpcResponseError | null > > {
268
+ options ?: UseSurrealRpcOptions < T > ,
269
+ ) {
270
270
const { database, key, token, watch, ...opts } = options || { }
271
271
272
- const params = computed < RpcRequest < R , 'query' > [ 'params' ] > ( ( ) => ( [ toValue ( sql ) , toValue ( vars ) ] ) )
272
+ const params = computed < RpcRequest < any , 'query' > [ 'params' ] > ( ( ) => ( [ toValue ( sql ) , toValue ( vars ) ] ) )
273
273
const _key = key ?? 'Sur_' + hash ( [ 'surreal' , 'query' , toValue ( params ) ] )
274
274
275
- return useSurrealRPC < R > ( { method : 'query' , params } , {
275
+ return useSurrealRPC < T > ( { method : 'query' , params } , {
276
276
...opts ,
277
277
database : database || overrides ?. database ,
278
278
token : token || overrides ?. token ,
@@ -296,7 +296,7 @@ export function useSurrealDB(overrides?: Overrides) {
296
296
async function remove < T = any > (
297
297
thing : MROGParam < any , 'delete' , 0 > ,
298
298
options ?: UseSurrealRpcOptions < T > ,
299
- ) : Promise < AsyncData < PickFrom < T , KeysOf < T > > | null , FetchError < any > | RpcResponseError | null > > {
299
+ ) : Promise < AsyncData < PickFrom < T , KeysOf < T > > | undefined , FetchError < any > | RpcResponseError | null > > {
300
300
const { database, key, immediate, token, watch, ...opts } = options || { }
301
301
302
302
const params = computed < RpcRequest < any , 'delete' > [ 'params' ] > ( ( ) => ( [ toValue ( thing ) ] ) )
@@ -327,7 +327,7 @@ export function useSurrealDB(overrides?: Overrides) {
327
327
async function select < T = any > (
328
328
thing : MROGParam < T , 'select' , 0 > ,
329
329
options ?: UseSurrealRpcOptions < T > ,
330
- ) : Promise < AsyncData < PickFrom < T , KeysOf < T > > | null , FetchError < any > | RpcResponseError | null > > {
330
+ ) : Promise < AsyncData < PickFrom < T , KeysOf < T > > | undefined , FetchError < any > | RpcResponseError | null > > {
331
331
const { database, key, token, watch, ...opts } = options || { }
332
332
333
333
const params = computed < RpcRequest < T , 'select' > [ 'params' ] > ( ( ) => ( [ toValue ( thing ) ] ) )
@@ -367,7 +367,7 @@ export function useSurrealDB(overrides?: Overrides) {
367
367
async function signin (
368
368
auth : MROGParam < any , 'signin' , 0 > ,
369
369
options ?: UseSurrealRpcOptions < string > ,
370
- ) : Promise < AsyncData < string | null , RpcResponseError | FetchError < any > | null > > {
370
+ ) : Promise < AsyncData < string | undefined , RpcResponseError | FetchError < any > | null > > {
371
371
const { NS , DB , SC } = toValue ( auth )
372
372
if ( ! SC && ! toValue ( auth ) . user && ! toValue ( auth ) . pass ) throw createError ( { statusCode : 400 , message : 'Wrong admin credentials' } )
373
373
const { database, immediate, key, token, watch, ...opts } = options || { }
@@ -420,7 +420,7 @@ export function useSurrealDB(overrides?: Overrides) {
420
420
options ?: Omit < UseSurrealRpcOptions < string > , 'database' > & {
421
421
database ?: keyof PublicRuntimeConfig [ 'surrealdb' ] [ 'databases' ] | { host ?: string }
422
422
} ,
423
- ) : Promise < AsyncData < string | null , RpcResponseError | FetchError < any > | null > > {
423
+ ) : Promise < AsyncData < string | undefined , RpcResponseError | FetchError < any > | null > > {
424
424
const { NS , DB , SC } = toValue ( auth )
425
425
if ( ! NS ) throw createError ( { statusCode : 400 , message : 'Missing NS param' } )
426
426
if ( ! DB ) throw createError ( { statusCode : 400 , message : 'Missing DB param' } )
@@ -463,7 +463,7 @@ export function useSurrealDB(overrides?: Overrides) {
463
463
thing : MROGParam < T , 'update' , 0 > ,
464
464
data ?: MROGParam < T , 'update' , 1 > ,
465
465
options ?: UseSurrealRpcOptions < T > ,
466
- ) : Promise < AsyncData < PickFrom < T , KeysOf < T > > | null , FetchError < any > | RpcResponseError | null > > {
466
+ ) : Promise < AsyncData < PickFrom < T , KeysOf < T > > | undefined , FetchError < any > | RpcResponseError | null > > {
467
467
const { database, immediate, key, token, watch, ...opts } = options || { }
468
468
469
469
const params = computed < RpcRequest < T , 'update' > [ 'params' ] > ( ( ) => ( [ toValue ( thing ) , toValue ( data ) ] ) )
@@ -487,7 +487,7 @@ export function useSurrealDB(overrides?: Overrides) {
487
487
} ) ,
488
488
} )
489
489
}
490
- async function version ( options ?: Overrides ) : Promise < AsyncData < string | null , FetchError < any > | null > > {
490
+ async function version ( options ?: Overrides ) : Promise < AsyncData < string | undefined , FetchError < any > | null > > {
491
491
return useSurrealFetch < string > ( 'version' , {
492
492
...$surrealFetchOptionsOverride ( {
493
493
database : options ?. database || overrides ?. database ,
0 commit comments