diff --git a/src/Core/ApiResponse.php b/src/Core/ApiResponse.php index c4d8a3a..9fca2b4 100644 --- a/src/Core/ApiResponse.php +++ b/src/Core/ApiResponse.php @@ -100,10 +100,10 @@ public function setContent(/* string|array|resource|StreamInterface */$body = "" * Push Content on Api Response * * @param string $where Where put content in content - * @param string|bool|array|int|null $content to push + * @param mixed $content to push * @return self */ - public function pushContent(string $where = "", string|bool|array|int|null $content = null):self { + public function pushContent(string $where = "", mixed $content = null):self { # Check where if(!$where) diff --git a/src/Driver/Model/Mongo.php b/src/Driver/Model/Mongo.php index 4498038..bd837e2 100644 --- a/src/Driver/Model/Mongo.php +++ b/src/Driver/Model/Mongo.php @@ -369,11 +369,33 @@ public function run():array { $validator = Mangodb::convertToMongoSchema($this->arguments["schema"]); # Get result - $result[] = $this->mongodb->insertToCollection($this->arguments["collection"], $data, $this->arguments["database"], true, $validator); + $currentResult = $this->mongodb->insertToCollection($this->arguments["collection"], $data, $this->arguments["database"], true, $validator); + + $result[] = [ + "MongoDB\InsertOneResult" => $currentResult, + "_id" => $currentResult->getInsertedId(), + "id" => (string) $currentResult->getInsertedId(), + "count" => $currentResult->getInsertedCount(), + "acknowledged" => $currentResult->isAcknowledged(), + ]; } } + + }else + # Find One by Id + if($this->id !== null && $this->id){ + + # Prepare $this->findOptions + $this->findOptions = [ + "filters" => [ + "_id" => $this->id, + ] + ]; + + # Find value + $result = $this->mongodb->findOne($this->arguments["collection"], $this->arguments["database"], $this->findOptions); }else{ diff --git a/src/Front/Library/Loader/Page.ts b/src/Front/Library/Loader/Page.ts index eba0973..28e3e5f 100644 --- a/src/Front/Library/Loader/Page.ts +++ b/src/Front/Library/Loader/Page.ts @@ -417,6 +417,15 @@ export default class Page { // Stop function return options; + // Declare new title + let titleNew = options.name; + + // Check titleNew + if(titleNew) + + // Set title + document.title = titleNew; + // Return options return options; diff --git a/src/Library/Database/Driver/Mangodb.php b/src/Library/Database/Driver/Mangodb.php index 3aeab7a..a5015a8 100644 --- a/src/Library/Database/Driver/Mangodb.php +++ b/src/Library/Database/Driver/Mangodb.php @@ -652,6 +652,57 @@ public function find(string $collectionName, string $database, array $options = } + /** + * Find One + * + * Find value + * + * @param string $collectionName + * @param string $database + * @param array $options = [ + * "filters":array + * ] + */ + public function findOne(string $collectionName, string $database, array $options = []):array|null { + + # Set result + $result = null; + + # Check input + if(!$collectionName || !$database) + + # Return result + return $result; + + # Connect to database + $database = $this->client->$database; + + # Connect to the collection + $collection = $database->$collectionName; + + # Set filters + $filters = isset($options["filters"]) && is_array($options["filters"]) + ? $options["filters"] + : [] + ; + + # Iteration filters + foreach($filters as $key => &$filter) + + # Check if _id + if($key === "_id") + + # Convert string + $filter = new ObjectId($filter); + + # Last result + $result = [$collection->findOne($filters, $options)]; + + # Return result + return $result === null ? [] : $result; + + } + /** * Find Last One *