Casting string to object
This commit is contained in:
parent
8cca937371
commit
f0f3211ef0
1 changed files with 2 additions and 2 deletions
|
@ -428,6 +428,8 @@ $utopia->post('/v1/database/:collectionId/documents')
|
||||||
}, 'Parent document property connection type. You can set this value to **assign**, **append** or **prepend**, default value is assign. Use when you want your new document to be a child of a parent document.', true)
|
}, 'Parent document property connection type. You can set this value to **assign**, **append** or **prepend**, default value is assign. Use when you want your new document to be a child of a parent document.', true)
|
||||||
->action(
|
->action(
|
||||||
function ($collectionId, $data, $read, $write, $parentDocument, $parentProperty, $parentPropertyType) use ($response, $projectDB, $webhook, $audit) {
|
function ($collectionId, $data, $read, $write, $parentDocument, $parentProperty, $parentPropertyType) use ($response, $projectDB, $webhook, $audit) {
|
||||||
|
$data = (is_string($data) && $result = json_decode($data, true)) ? $result : $data; // Cast to JSON array
|
||||||
|
|
||||||
if (empty($data)) {
|
if (empty($data)) {
|
||||||
throw new Exception('Missing payload', 400);
|
throw new Exception('Missing payload', 400);
|
||||||
}
|
}
|
||||||
|
@ -436,8 +438,6 @@ $utopia->post('/v1/database/:collectionId/documents')
|
||||||
throw new Exception('$uid is not allowed for creating new documents, try update instead', 400);
|
throw new Exception('$uid is not allowed for creating new documents, try update instead', 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = (is_string($data) && $result = json_decode($data, true)) ? $result : $data; // Cast to JSON array
|
|
||||||
|
|
||||||
$collection = $projectDB->getDocument($collectionId/*, $isDev*/);
|
$collection = $projectDB->getDocument($collectionId/*, $isDev*/);
|
||||||
|
|
||||||
if (is_null($collection->getUid()) || Database::SYSTEM_COLLECTION_COLLECTIONS != $collection->getCollection()) {
|
if (is_null($collection->getUid()) || Database::SYSTEM_COLLECTION_COLLECTIONS != $collection->getCollection()) {
|
||||||
|
|
Loading…
Reference in a new issue