feat: Add support for dot notation on array fields of Parse Object (#9115)
This commit is contained in:
@@ -1851,6 +1851,14 @@ class DatabaseController {
|
||||
// only valid ops that produce an actionable result
|
||||
// the op may have happened on a keypath
|
||||
this._expandResultOnKeyPath(response, key, result);
|
||||
// Revert array to object conversion on dot notation for arrays (e.g. "field.0.key")
|
||||
if (key.includes('.')) {
|
||||
const [field, index] = key.split('.');
|
||||
const isArrayIndex = Array.from(index).every(c => c >= '0' && c <= '9');
|
||||
if (isArrayIndex && Array.isArray(result[field]) && !Array.isArray(response[field])) {
|
||||
response[field] = result[field];
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return Promise.resolve(response);
|
||||
|
||||
Reference in New Issue
Block a user