File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -210,6 +210,13 @@ export function assignTempId(state, item) {
210
210
return newId
211
211
}
212
212
213
+ function stringifyIfObject ( val ) : string | any {
214
+ if ( typeof val === 'object' && val != null ) {
215
+ return val . toString ( )
216
+ }
217
+ return val
218
+ }
219
+
213
220
/**
214
221
* Get the id from a record in this order:
215
222
* 1. the `idField`
@@ -218,20 +225,19 @@ export function assignTempId(state, item) {
218
225
* @param item
219
226
* @param idField
220
227
*/
221
- export function getId ( item , idField ) {
228
+ export function getId ( item , idField ? ) {
222
229
if ( ! item ) {
223
230
return
224
231
}
225
232
if ( item [ idField ] != null || item . hasOwnProperty ( idField ) ) {
226
- return item [ idField ]
233
+ return stringifyIfObject ( item [ idField ] )
227
234
}
228
235
if ( item . id != null || item . hasOwnProperty ( 'id' ) ) {
229
- return item . id
236
+ return stringifyIfObject ( item . id )
230
237
}
231
238
if ( item . _id != null || item . hasOwnProperty ( '_id' ) ) {
232
- return item . _id
239
+ return stringifyIfObject ( item . _id )
233
240
}
234
-
235
241
}
236
242
237
243
// Creates a Model class name from the last part of the servicePath
You can’t perform that action at this time.
0 commit comments