MCPcopy
hub / github.com/apache/devlake / NewModelApiHelper

Function NewModelApiHelper

backend/helpers/pluginhelper/api/model_api_helper.go:45–64  ·  view source on GitHub ↗
(
	basicRes context.BasicRes,
	dalHelper *srvhelper.ModelSrvHelper[M],
	pkPathVarNames []string, // path variable names of primary key
	sterilizer func(m M) M,
)

Source from the content-addressed store, hash-verified

43}
44
45func NewModelApiHelper[M dal.Tabler](
46 basicRes context.BasicRes,
47 dalHelper *srvhelper.ModelSrvHelper[M],
48 pkPathVarNames []string, // path variable names of primary key
49 sterilizer func(m M) M,
50) *ModelApiHelper[M] {
51 m := new(M)
52 modelName := fmt.Sprintf("%T", m)
53 modelApiHelper := &ModelApiHelper[M]{
54 basicRes: basicRes,
55 dalHelper: dalHelper,
56 log: basicRes.GetLogger().Nested(fmt.Sprintf("%s_dal", modelName)),
57 modelName: modelName,
58 pkPathVarNames: pkPathVarNames,
59 }
60 if sterilizer != nil {
61 modelApiHelper.sterilizers = []func(m M) M{sterilizer}
62 }
63 return modelApiHelper
64}
65
66func (self *ModelApiHelper[M]) Post(input *plugin.ApiResourceInput) (*plugin.ApiResourceOutput, errors.Error) {
67 model := new(M)

Callers

nothing calls this directly

Calls 2

NestedMethod · 0.65
GetLoggerMethod · 0.65

Tested by

no test coverage detected