@@ -81,11 +81,16 @@ export default async function linkContactToDoc(req) {
81
81
const updateDoc = new Parse . Object ( 'contracts_Document' ) ;
82
82
updateDoc . id = docId ;
83
83
const signers = _docRes ?. Signers || [ ] ;
84
- signers . push ( {
84
+ const signerobj = {
85
85
__type : 'Pointer' ,
86
86
className : 'contracts_Contactbook' ,
87
87
objectId : existContact . id ,
88
- } ) ;
88
+ } ;
89
+ // The splice method is used to add a signer at the desired index
90
+ // index is the variable where the signer needs to be added
91
+ // 0 indicates that no elements should be deleted
92
+ // signerobj is the reference to the signer object
93
+ signers . splice ( index , 0 , signerobj ) ;
89
94
updateDoc . set ( 'Signers' , signers ) ;
90
95
91
96
Placeholders [ index ] = {
@@ -128,11 +133,16 @@ export default async function linkContactToDoc(req) {
128
133
const updateDoc = new Parse . Object ( 'contracts_Document' ) ;
129
134
updateDoc . id = docId ;
130
135
const signers = _docRes ?. Signers || [ ] ;
131
- signers . push ( {
136
+ const signerobj = {
132
137
__type : 'Pointer' ,
133
138
className : 'contracts_Contactbook' ,
134
139
objectId : contactRes . id ,
135
- } ) ;
140
+ } ;
141
+ // The splice method is used to add a signer at the desired index
142
+ // index is the variable where the signer needs to be added
143
+ // 0 indicates that no elements should be deleted
144
+ // signerobj is the reference to the signer object
145
+ signers . splice ( index , 0 , signerobj ) ;
136
146
updateDoc . set ( 'Signers' , signers ) ;
137
147
138
148
Placeholders [ index ] = {
@@ -175,11 +185,16 @@ export default async function linkContactToDoc(req) {
175
185
const updateDoc = new Parse . Object ( 'contracts_Document' ) ;
176
186
updateDoc . id = docId ;
177
187
const signers = _docRes ?. Signers || [ ] ;
178
- signers . push ( {
188
+ const signerobj = {
179
189
__type : 'Pointer' ,
180
190
className : 'contracts_Contactbook' ,
181
191
objectId : contactRes . id ,
182
- } ) ;
192
+ } ;
193
+ // The splice method is used to add a signer at the desired index
194
+ // index is the variable where the signer needs to be added
195
+ // 0 indicates that no elements should be deleted
196
+ // signerobj is the reference to the signer object
197
+ signers . splice ( index , 0 , signerobj ) ;
183
198
updateDoc . set ( 'Signers' , signers ) ;
184
199
185
200
Placeholders [ index ] = {
@@ -227,13 +242,17 @@ export default async function linkContactToDoc(req) {
227
242
const updateDoc = new Parse . Object ( 'contracts_Document' ) ;
228
243
updateDoc . id = docId ;
229
244
const signers = _docRes ?. Signers || [ ] ;
230
- signers . push ( {
245
+ const signerobj = {
231
246
__type : 'Pointer' ,
232
247
className : 'contracts_Contactbook' ,
233
248
objectId : contactRes . id ,
234
- } ) ;
249
+ } ;
250
+ // The splice method is used to add a signer at the desired index
251
+ // index is the variable where the signer needs to be added
252
+ // 0 indicates that no elements should be deleted
253
+ // signerobj is the reference to the signer object
254
+ signers . splice ( index , 0 , signerobj ) ;
235
255
updateDoc . set ( 'Signers' , signers ) ;
236
-
237
256
Placeholders [ index ] = {
238
257
...Placeholders [ index ] ,
239
258
signerObjId : contactRes . id ,
0 commit comments