CouchDB ODM

基于CouchDB的Document Mapper。(A Document Mapper based on CouchDB.)

Github stars Tracking Chart

CouchDB ODM

Doctrine CouchDB是PHP和CouchDB文档之间的映射器。 它使用元数据映射模式将文档映射到普通的旧php对象,不需要任何类型的ActiveRecord模式或基类。

元数据映射可以通过注释、xml、yaml或php完成。 使用注释映射到CouchDB的示例PHP对象如下所示:

/**
 * @Document
 */
class Article
{
    /** @Id */
    private $id;

    /**
     * @Field(type="string")
     */
    private $topic;

    /**
     * @Field(type="string")
     */
    private $text;

    /**
     * @ReferenceOne(targetDocument="User")
     */
    private $author;

    // a bunch of setters and getters
}

此文档的简单工作流程如下所示:

 <?php
$article = new Article();
$article->setTopic("Doctrine CouchDB");
$article->setText("Documentation");
$article->setAuthor(new Author("beberlei"));

// creating the document
$dm->persist($article);
$dm->flush();

$article = $dm->find("Article", 1234);
$article->setText("Documentation, and more documentation!");

// update the document
$dm->flush();

// removing the document
$dm->remove($article);
$dm->flush();

您可以使用每个git checkout的沙箱/文件夹中提供的沙箱,或者阅读文档 http://docs.doctrine-project.org/projects/doctrine-couchdb/en/latest/

Main metrics

Overview
Name With Ownerdoctrine/couchdb-odm
Primary LanguagePHP
Program languagePHP (Language Count: 2)
PlatformBSD, Linux, Mac, Windows
License:MIT License
所有者活动
Created At2010-09-18 09:37:23
Pushed At2019-09-02 14:16:11
Last Commit At2019-03-12 02:20:21
Release Count3
Last Release Namev1.0.0-alpha3 (Posted on 2015-11-11 19:36:57)
First Release Name1.0.0alpha1 (Posted on 2011-05-27 20:58:54)
用户参与
Stargazers Count149
Watchers Count14
Fork Count53
Commits Count512
Has Issues Enabled
Issues Count55
Issue Open Count20
Pull Requests Count64
Pull Requests Open Count10
Pull Requests Close Count25
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private

CouchDB ODM

Build Status
Scrutinizer Quality Score

Doctrine CouchDB is a mapper between PHP and CouchDB documents. It uses a metadata mapping
pattern to map the documents to plain old php objects, no ActiveRecord pattern or base class
of any kind is necessary.

Metadata mapping can be done through annotations, xml, yaml or php. A sample PHP object
that is mapped to CouchDB with annotations looks like this:

/**
 * @Document
 */
class Article
{
    /** @Id */
    private $id;

    /**
     * @Field(type="string")
     */
    private $topic;

    /**
     * @Field(type="string")
     */
    private $text;

    /**
     * @ReferenceOne(targetDocument="User")
     */
    private $author;

    // a bunch of setters and getters
}

A simple workflow with this document looks like:

<?php
$article = new Article();
$article->setTopic("Doctrine CouchDB");
$article->setText("Documentation");
$article->setAuthor(new Author("beberlei"));

// creating the document
$dm->persist($article);
$dm->flush();

$article = $dm->find("Article", 1234);
$article->setText("Documentation, and more documentation!");

// update the document
$dm->flush();

// removing the document
$dm->remove($article);
$dm->flush();

You can play around with the sandbox shipped in the sandbox/ folder of every git checkout
or read the documentation at https://www.doctrine-project.org/projects/doctrine-couchdb-odm/en/latest/index.html