Using the fauxton client with Bingo MVC and ReactJS

"chemem/fauxton-client": "dev-master"
const DB_NAME = 'nba_info';const DB_USER = '<couch-db-username>';const DB_PASS = '<couch-db-password>';const DB_HOST = '<couch-db-url>'; //default is http://localhost:5984
$router->inject('CouchDb', function ($c) {
$db = new \Chemem\Fauxton\DatabaseActions;
$doc = new \Chemem\Fauxton\DocumentActions;
$doc::setReturnType(false); //returns a decoded JSON strings
$db->useFauxtonLogin(\App\Config::DB_USER, \App\Config::DB_PASS);
return new \App\Models\Basketball($db, $doc, $qb, $queries);
$router->addRoute('nba', [
'controller' => 'Basketball',
'action' => 'index'
<?phpnamespace App\Models;final class Basketball
protected $db;

protected $doc;
public function __construct($db, $doc)
$this->db = $db;
$this->doc = $doc;
public function getAllDocs()
$rows = $this->doc->showAllDocuments(Config::DB_NAME)->rows;
$keys = [];
for ($x = 0; $x < count($rows); $x++) {
$keys[$x] = $rows[$x]->key;
return $this->doc->getDocsByKey(
['keys' => $keys]
public function createDoc(array $doc)
$id = $this->doc->generateId()->uuids[0];//unique id
return $this->doc->createDocument($id, Config::DB_NAME, $doc);
The interface for the application.



I write PHP and I know things — kind of.

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store