Skip to content

Generics using using table values #2181

Answered by carsakiller
GiuseppeIII asked this question in Q&A
Discussion options

You must be logged in to vote

Unfortunately, generic classes are not yet supported. However, once they are, your code would likely look like this:

---@class get_params<T>
---@field endpoint Endpoint db table you want to get
---@field where Where | Where[] what fields to query table on
---@field return_fields table<T, any> | "ALL" what fields to return
---@field on_empty? OnEmpty what to do if no data is returned, defaults to NOTHING

---@generic T
---@param get_params get_params<T>
---@return table<T, any>?
function Connector.get(get_params) end

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by GiuseppeIII
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants