Is there way to get only one field from tarantool db, not whole table?
Currently my request looks like:
result := Result{}
err := tConn.Do(tarantool.NewSelectRequest(spaceName).
Context(ctx).
Index("primary").
Key(tarantool.IntKey{I: id}).
Limit(1),
).GetTyped(&result)
but want something like this:
result := Result{}
err := tConn.Do(tarantool.NewSelectRequest(spaceName).
Context(ctx).
Index("primary").
Key(tarantool.IntKey{I: id}).
QueryFieldName("field_name").
Limit(1),
).GetTyped(&result)
Is it even possible?
I tried to use sql syntax with go-tarantool. But it's going to be deprecated. And i doubt that perfomance wise, and that it's really getting only one field under the hood. Didn't find anything in official godoc nor googling didn't help me.
There is no proper API in select. If you want to fetch a single tuple field from the Tarantool instance (and not "fetch all, extract one on the client"), you should create a Lua store procedure and Call
it or send the procedure code in Eval
request. Lua code will be something like
return box.space['my_space'].index['my_index']:select({key})[my_field]
You can pass arguments into these procedures as well.