Skip to content

Commit fdf575f

Browse files
committed
Created new example scripts
1 parent 6883b0d commit fdf575f

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

examples/insert-doc.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php declare(strict_types=1);
2+
3+
require dirname(__DIR__) . '/vendor/autoload.php';
4+
5+
use \React\EventLoop\Factory;
6+
use \Chemem\Fauxton\Actions\Action;
7+
use \Psr\Http\Message\ResponseInterface;
8+
9+
$loop = Factory::create();
10+
11+
$insert = Action::init($loop)->insertSingle('your_database', [
12+
'name' => isset($argv[1]) ? $argv[1] : 'loki',
13+
'age' => isset($argv[2]) ? $argv[2] : 1000
14+
])->then(
15+
function (ResposneInterface $response) {
16+
echo $response->getBody();
17+
},
18+
function (\Exception $error) {
19+
echo $error->getMessage();
20+
}
21+
);
22+
23+
$loop->run();

examples/query-view.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php declare(strict_types=1);
2+
3+
require dirname(__DIR__) . '/vendor/autoload.php';
4+
5+
use \React\EventLoop\Factory;
6+
use \Chemem\Fauxton\Actions\Action;
7+
use \Psr\Http\Message\ResponseInterface;
8+
9+
$loop = Factory::create();
10+
11+
$query = Action::init($loop)->queryView('your_database', 'design_doc', 'view_name', [
12+
'descending' => 'true',
13+
'group' => 'false'
14+
])->then(
15+
function (ResponseInterface $response) {
16+
echo $response->getContents();
17+
},
18+
function (\Exception $error) {
19+
echo $error->getMessage();
20+
}
21+
);
22+
23+
$loop->run();

0 commit comments

Comments
 (0)