Skip to content

Commit 9d0938e

Browse files
committed
Updated updateMerge function
1 parent 6c9ca10 commit 9d0938e

13 files changed

+1370
-1346
lines changed

README.md

+40-40
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,40 @@
1-
# fauxton
2-
3-
[![Build Status](https://travis-ci.org/php-api-clients/fauxton.svg?branch=master)](https://travis-ci.org/php-api-clients/fauxton)
4-
[![codecov](https://codecov.io/gh/php-api-clients/fauxton/branch/master/graph/badge.svg)](https://codecov.io/gh/php-api-clients/fauxton)
5-
6-
Async version of the [fauxton-client](https://github.com/ace411/fauxton-client) powered by [ReactPHP](https://reactphp.org). As such, it offers the cogencies of CouchDB interactions in a non-blocking IO environment.
7-
8-
## Requirements
9-
10-
- PHP 7.1+
11-
12-
## Installation
13-
14-
The fauxton library is available on Packagist. To install it, type the following on your preferred
15-
command-line interface:
16-
17-
```
18-
composer require php-api-clients/fauxton
19-
```
20-
21-
## Documentation
22-
23-
I advise that you read the [official CouchDB documentation](http://docs.couchdb.org)
24-
so as to better understand fauxton. Also, check out the examples in the [examples folder](https://github.com/php-api-clients/fauxton-client/tree/master/examples) for more perspective.
25-
26-
## Running the unit tests
27-
28-
Follow the following steps:
29-
30-
- Create a database called ```testdb```
31-
32-
- Type the following in a command line of your choosing:
33-
34-
```
35-
vendor/bin/phpunit -c phpunit.xml.dist
36-
```
37-
38-
## Dealing with problems
39-
40-
Endeavor to create an issue on GitHub when the need arises or send an email to [email protected]
1+
# fauxton
2+
3+
[![Build Status](https://travis-ci.org/php-api-clients/fauxton.svg?branch=master)](https://travis-ci.org/php-api-clients/fauxton)
4+
[![codecov](https://codecov.io/gh/php-api-clients/fauxton/branch/master/graph/badge.svg)](https://codecov.io/gh/php-api-clients/fauxton)
5+
6+
Async version of the [fauxton-client](https://github.com/ace411/fauxton-client) powered by [ReactPHP](https://reactphp.org). As such, it offers the cogencies of CouchDB interactions in a non-blocking IO environment.
7+
8+
## Requirements
9+
10+
- PHP 7.1+
11+
12+
## Installation
13+
14+
The fauxton library is available on Packagist. To install it, type the following on your preferred
15+
command-line interface:
16+
17+
```
18+
composer require php-api-clients/fauxton
19+
```
20+
21+
## Documentation
22+
23+
I advise that you read the [official CouchDB documentation](http://docs.couchdb.org)
24+
so as to better understand fauxton. Also, check out the examples in the [examples folder](https://github.com/php-api-clients/fauxton-client/tree/master/examples) for more perspective.
25+
26+
## Running the unit tests
27+
28+
Follow the following steps:
29+
30+
- Create a database called ```testdb```
31+
32+
- Type the following in a command line of your choosing:
33+
34+
```
35+
vendor/bin/phpunit -c phpunit.xml.dist
36+
```
37+
38+
## Dealing with problems
39+
40+
Endeavor to create an issue on GitHub when the need arises or send an email to [email protected]

composer.json

+48-48
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,48 @@
1-
{
2-
"name": "api-clients/fauxton",
3-
"description": "Async version of chemem/fauxton-client built on top of ReactPHP.",
4-
"type": "library",
5-
"license": "MIT",
6-
"minimum-stability": "dev",
7-
"authors": [
8-
{
9-
"name": "Lochemem Bruno Michael",
10-
"email": "[email protected]"
11-
}
12-
],
13-
"require-dev": {
14-
"clue/block-react": "~1",
15-
"phpunit/phpunit": "~6.0",
16-
"giorgiosironi/eris": "~0.10"
17-
},
18-
"require": {
19-
"php": ">=7.1",
20-
"chemem/bingo-functional": "~1",
21-
"composer/ca-bundle": "~1",
22-
"clue/buzz-react": "~2",
23-
"react/filesystem": "~0"
24-
},
25-
"autoload": {
26-
"psr-4": {
27-
"Chemem\\Fauxton\\": "src/"
28-
},
29-
"files": [
30-
"src/Http/functions.php",
31-
"src/Actions/functions.php"
32-
]
33-
},
34-
"autoload-dev": {
35-
"psr-4": {
36-
"Chemem\\Fauxton\\Tests\\": "tests"
37-
}
38-
},
39-
"bin": ["fauxton-config"],
40-
"extra": {
41-
"branch-alias": {
42-
"dev-master": "1.0-dev"
43-
}
44-
},
45-
"scripts": {
46-
"test": "phpunit -c phpunit.xml.dist"
47-
}
48-
}
1+
{
2+
"name": "api-clients/fauxton",
3+
"description": "Async version of chemem/fauxton-client built on top of ReactPHP.",
4+
"type": "library",
5+
"license": "MIT",
6+
"minimum-stability": "dev",
7+
"authors": [
8+
{
9+
"name": "Lochemem Bruno Michael",
10+
"email": "[email protected]"
11+
}
12+
],
13+
"require-dev": {
14+
"clue/block-react": "~1",
15+
"phpunit/phpunit": "~6.0",
16+
"giorgiosironi/eris": "~0.10"
17+
},
18+
"require": {
19+
"php": ">=7.1",
20+
"chemem/bingo-functional": "~1",
21+
"composer/ca-bundle": "~1",
22+
"clue/buzz-react": "~2",
23+
"react/filesystem": "~0"
24+
},
25+
"autoload": {
26+
"psr-4": {
27+
"Chemem\\Fauxton\\": "src/"
28+
},
29+
"files": [
30+
"src/Http/functions.php",
31+
"src/Actions/functions.php"
32+
]
33+
},
34+
"autoload-dev": {
35+
"psr-4": {
36+
"Chemem\\Fauxton\\Tests\\": "tests"
37+
}
38+
},
39+
"bin": ["fauxton-config"],
40+
"extra": {
41+
"branch-alias": {
42+
"dev-master": "1.0-dev"
43+
}
44+
},
45+
"scripts": {
46+
"test": "phpunit -c phpunit.xml.dist"
47+
}
48+
}

examples/all-docs.php

+20-20
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
<?php
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-
$docs = Action::init($loop)->allDocs('your_database')->then(
12-
function (ResponseInterface $response) {
13-
echo $response->getBody();
14-
},
15-
function (\Exception $error) {
16-
echo $error->getMessage();
17-
}
18-
);
19-
20-
$loop->run();
1+
<?php
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+
$docs = Action::init($loop)->allDocs('your_database')->then(
12+
function (ResponseInterface $response) {
13+
echo $response->getBody();
14+
},
15+
function (\Exception $error) {
16+
echo $error->getMessage();
17+
}
18+
);
19+
20+
$loop->run();

examples/insert-doc.php

+23-23
Original file line numberDiff line numberDiff line change
@@ -1,23 +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();
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

+23-23
Original file line numberDiff line numberDiff line change
@@ -1,23 +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();
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();

examples/timer.php

+39-39
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,39 @@
1-
<?php declare(strict_types=1);
2-
3-
require dirname(__DIR__) . '/vendor/autoload.php';
4-
5-
use \Chemem\Fauxton\Actions\Action;
6-
use \Clue\React\Buzz\Browser;
7-
8-
const LIMIT = 5; //arbitrary limit value
9-
10-
const TIMER = 10; //arbitrary periodic loop timer value
11-
12-
$loop = \React\EventLoop\Factory::create();
13-
14-
$since = -5; //arbitrary since parameter value
15-
16-
$action = Action::init($loop);
17-
18-
$loop->addPeriodicTimer(TIMER, function () use (&$action, &$since, &$loop) {
19-
$since += 5;
20-
$action->changes('your_database', [
21-
'descending' => 'true',
22-
'since' => $since,
23-
'limit' => LIMIT
24-
])
25-
->then(
26-
function ($result) {
27-
echo $result->getBody();
28-
},
29-
function ($error) {
30-
echo $error->getMessage();
31-
}
32-
);
33-
34-
if ($since == 25) {
35-
$loop->cancelTimer(); //cancel timer after 5 log operations
36-
}
37-
});
38-
39-
$loop->run();
1+
<?php declare(strict_types=1);
2+
3+
require dirname(__DIR__) . '/vendor/autoload.php';
4+
5+
use \Chemem\Fauxton\Actions\Action;
6+
use \Clue\React\Buzz\Browser;
7+
8+
const LIMIT = 5; //arbitrary limit value
9+
10+
const TIMER = 10; //arbitrary periodic loop timer value
11+
12+
$loop = \React\EventLoop\Factory::create();
13+
14+
$since = -5; //arbitrary since parameter value
15+
16+
$action = Action::init($loop);
17+
18+
$loop->addPeriodicTimer(TIMER, function () use (&$action, &$since, &$loop) {
19+
$since += 5;
20+
$action->changes('your_database', [
21+
'descending' => 'true',
22+
'since' => $since,
23+
'limit' => LIMIT
24+
])
25+
->then(
26+
function ($result) {
27+
echo $result->getBody();
28+
},
29+
function ($error) {
30+
echo $error->getMessage();
31+
}
32+
);
33+
34+
if ($since == 25) {
35+
$loop->cancelTimer(); //cancel timer after 5 log operations
36+
}
37+
});
38+
39+
$loop->run();

0 commit comments

Comments
 (0)