MCPcopy Index your code
hub / github.com/pocketbase/pocketbase / AddAt

Method AddAt

core/fields_list.go:129–141  ·  view source on GitHub ↗

AddAt is the same as Add but insert/move the fields at the specific position. If pos < 0, then this method acts the same as calling Add. If pos > FieldsList total items, then the specified fields are inserted/moved at the end of the list.

(pos int, fields ...Field)

Source from the content-addressed store, hash-verified

127//
128// If pos > FieldsList total items, then the specified fields are inserted/moved at the end of the list.
129func (l *FieldsList) AddAt(pos int, fields ...Field) {
130 total := len(*l)
131
132 for i, f := range fields {
133 if pos < 0 {
134 l.add(-1, f)
135 } else if pos > total {
136 l.add(total+i, f)
137 } else {
138 l.add(pos+i, f)
139 }
140 }
141}
142
143// AddMarshaledJSON parses the provided raw json data and adds the
144// found fields into the current list (following the same rule as the Add method).

Callers 2

TestFieldsListAddAtFunction · 0.95
AddMarshaledJSONAtMethod · 0.95

Calls 1

addMethod · 0.95

Tested by 1

TestFieldsListAddAtFunction · 0.76