MCPcopy
hub / github.com/crowdsecurity/crowdsec / createSpec

Method createSpec

pkg/database/ent/allowlist_create.go:189–236  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

187}
188
189func (_c *AllowListCreate) createSpec() (*AllowList, *sqlgraph.CreateSpec) {
190 var (
191 _node = &AllowList{config: _c.config}
192 _spec = sqlgraph.NewCreateSpec(allowlist.Table, sqlgraph.NewFieldSpec(allowlist.FieldID, field.TypeInt))
193 )
194 _spec.OnConflict = _c.conflict
195 if value, ok := _c.mutation.CreatedAt(); ok {
196 _spec.SetField(allowlist.FieldCreatedAt, field.TypeTime, value)
197 _node.CreatedAt = value
198 }
199 if value, ok := _c.mutation.UpdatedAt(); ok {
200 _spec.SetField(allowlist.FieldUpdatedAt, field.TypeTime, value)
201 _node.UpdatedAt = value
202 }
203 if value, ok := _c.mutation.Name(); ok {
204 _spec.SetField(allowlist.FieldName, field.TypeString, value)
205 _node.Name = value
206 }
207 if value, ok := _c.mutation.FromConsole(); ok {
208 _spec.SetField(allowlist.FieldFromConsole, field.TypeBool, value)
209 _node.FromConsole = value
210 }
211 if value, ok := _c.mutation.Description(); ok {
212 _spec.SetField(allowlist.FieldDescription, field.TypeString, value)
213 _node.Description = value
214 }
215 if value, ok := _c.mutation.AllowlistID(); ok {
216 _spec.SetField(allowlist.FieldAllowlistID, field.TypeString, value)
217 _node.AllowlistID = value
218 }
219 if nodes := _c.mutation.AllowlistItemsIDs(); len(nodes) > 0 {
220 edge := &sqlgraph.EdgeSpec{
221 Rel: sqlgraph.M2M,
222 Inverse: false,
223 Table: allowlist.AllowlistItemsTable,
224 Columns: allowlist.AllowlistItemsPrimaryKey,
225 Bidi: false,
226 Target: &sqlgraph.EdgeTarget{
227 IDSpec: sqlgraph.NewFieldSpec(allowlistitem.FieldID, field.TypeInt),
228 },
229 }
230 for _, k := range nodes {
231 edge.Target.Nodes = append(edge.Target.Nodes, k)
232 }
233 _spec.Edges = append(_spec.Edges, edge)
234 }
235 return _node, _spec
236}
237
238// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
239// of the `INSERT` statement. For example:

Callers 2

sqlSaveMethod · 0.95
SaveMethod · 0.45

Calls 8

FromConsoleMethod · 0.80
AllowlistIDMethod · 0.80
AllowlistItemsIDsMethod · 0.80
DescriptionMethod · 0.65
CreatedAtMethod · 0.45
SetFieldMethod · 0.45
UpdatedAtMethod · 0.45
NameMethod · 0.45

Tested by

no test coverage detected