aarcarv/laravel-couchdb
Composer 安装命令:
composer require aarcarv/laravel-couchdb
包简介
CouchDB database driver for Laravel 4
README 文档
README
CouchDB database driver for Laravel 4
Dependencies
laravel-couchdb uses doctrine/couchdb-client. This package will be automatically downloaded for you via composer.
Installation
Add the package to your composer.json and run composer update.
{
"require": {
"rbewley4/laravel-couchdb": "dev-master"
}
}
Add the service provider in app/config/app.php:
'Rbewley4\Laravel\Couchdb\CouchdbServiceProvider',
The service provider will register a couchdb database extension with the original database manager. There is no need to register additional facades or objects. When using couchdb connections, Laravel will automatically provide you with the corresponding couchdb objects.
Configuration
Change your default database connection name in app/config/database.php:
'default' => 'couchdb',
And add a new couchdb connection:
'couchdb' => array( 'driver' => 'couchdb', 'type' => 'socket', 'host' => 'localhost', 'ip' => null, 'port' => 5984, 'dbname' => 'database', 'user' => 'username', 'password' => 'password', 'logging' => false, ),
Eloquent, Query Builder, Schema Builder
Sorry, we do not support these components at this time.
Examples
laravel-couchdb provides you with direct access to a CouchDBClient object, and expects you to use it for all CouchDB interaction.
For more information on CouchDBClient, see doctrine/couchdb-client.
Get handle to CouchDBClient
/** * @var \Rbewley4\Laravel\Couchdb\CouchdbConnection */ $connection = DB::connection('couchdb'); /** * @var \Doctrine\CouchDB\CouchDBClient */ $couchdb = $connection->getCouchDB();
Note: you can invoke methods on CouchDBClient by invoking them on CouchdbConnection. This is accomplished via the use of magic methods.
Create/Update/Find Document
Here we demonstrate three different operations that you can perform on CouchDB, and we show three different ways that you can invoke these methods:
$connection = DB::connection('couchdb'); $couchdb = $connection->getCouchDB(); list($id, $rev) = $connection->postDocument(array('foo' => 'bar')); $couchdb->putDocument(array('foo' => 'baz'), $id, $rev); $doc = DB::connection('couchdb')->findDocument($id);
Note that all three methods can be called on $connection or $couchdb.
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-11-03