承接 maurymmarques/couchdb-datasource-plugin 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

maurymmarques/couchdb-datasource-plugin

Composer 安装命令:

composer require maurymmarques/couchdb-datasource-plugin

包简介

CouchDB datasource is a CakePHP plugin to facilitate the communication from CakePHP application to CouchDB database.

README 文档

README

CouchDB datasource is a way to facilitate the communication from CakePHP application to CouchDB database.

DataSources are the link between models and the source of data that models represent.

CouchDB is an open source document-oriented database written mostly in the Erlang programming language.

Version

Written for CakePHP 2.x

Copyright

Copyright (c) 2011 Maury M. Marques

Installation

You can install this plugin using Composer, GIT Submodule, GIT Clone or Manually

[Using Composer]

Add the plugin to your project's composer.json - something like this:

{
  "require": {
    "maurymmarques/couchdb-datasource-plugin": "dev-master"
  },
  "extra": {
    "installer-paths": {
      "app/Plugin/CouchDB": ["maurymmarques/couchdb-datasource-plugin"]
    }
  }
}

Then just run composer install

Because this plugin has the type cakephp-plugin set in it's own composer.json, composer knows to install it inside your /Plugin directory, rather than in the usual vendors file.

[GIT Submodule]

In your app directory (app/Plugin) type:

git submodule add git://github.com/maurymmarques/couchdb-datasource.git Plugin/CouchDB
git submodule init
git submodule update

[GIT Clone]

In your plugin directory (app/Plugin or plugins) type:

git clone https://github.com/maurymmarques/couchdb-datasource.git CouchDB

[Manual]

  • Download the CouchDB archive.
  • Unzip that download.
  • Rename the resulting folder to CouchDB
  • Then copy this folder into app/Plugin/ or plugins

Configuration

Bootstrap the plugin in app/Config/bootstrap.php:

CakePlugin::load('CouchDB');

Connection in app/Config/database.php:

class DATABASE_CONFIG {

	public $default = array(
		'datasource'	=> 'CouchDB.CouchDBSource',
		'persistent'	=> false,
		'host'			=> 'localhost',
		'port'			=> '5984',
		'login'			=> 'root',
		'password'		=> 'root',
		'database'		=> null,
		'prefix'		=> ''
	);

}

Usage

The datasource works basically like CakePHP

Creating a model

class Post extends AppModel {

	public $schema = array(
		'title' => array(
			'type' => 'string',
			'null' => true,
			'key' => 'primary',
			'length' => 32
		)
	);

}

You can set another CouchDB database name in your model using the attribute Model::useTable

public $useTable = 'posts';

Saving a document

$data = array('title' => 'My new title');
$this->Post->save($data);

// Id
$this->Post->id;

// Revision
$this->Post->rev;

Search for a document

$conditions = array('Post.id' => $this->Post->id);
$result = $this->Post->find('first', compact('conditions'));

Search for a document by specific revision

$conditions = array('Post.id' => $this->Post->id, 'Post.rev' => $this->Post->rev);
$result = $this->Post->find('first', compact('conditions'));

Change a document (changing the last revision)

$data = array('title' => 'My new title');
$this->Post->id = '8e64f1eadab2b3b32c94ef2scf3094420';
$this->Post->save($data);

Change a document to a particular revision

$data = array('title' => 'My new title');
$this->Post->id = '8e64f1eadab2b3b32c94ef2scf3094420';
$this->Post->rev = '26-5cd5713759905feeee9b384edc4cfb61';
$this->Post->save($data);

Deleting a document

$this->Post->id = '8e64f1eadab2b3b32c94ef2scf3094420';
$this->Post->delete($data);

REST

You can use the methods: curlGet, curlPost, curlPut, curlDelete

$post = array(
	'source' => 'post',
	'target' => 'post-replicate',
	'countinuos' => true
);

$return = $this->Post->curlPost('_replicate', $post, true, false);

统计信息

  • 总下载量: 31
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 16
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 16
  • Watchers: 4
  • Forks: 5
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-02-08

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固