1
0
Fork 0
mirror of synced 2024-06-26 10:10:57 +12:00

Casting string to object

This commit is contained in:
eldadfux 2019-10-03 23:59:06 +03:00
parent 8cca937371
commit f0f3211ef0

View file

@ -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)
->action(
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)) {
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);
}
$data = (is_string($data) && $result = json_decode($data, true)) ? $result : $data; // Cast to JSON array
$collection = $projectDB->getDocument($collectionId/*, $isDev*/);
if (is_null($collection->getUid()) || Database::SYSTEM_COLLECTION_COLLECTIONS != $collection->getCollection()) {