fredpalas/couchbase-bundle

使用couchbase与doctrine结合

0.1.2 2018-02-18 11:42 UTC

This package is not auto-updated.

Last update: 2024-09-29 04:43:14 UTC


README

用于连接Couchbase与Doctrine ORM的Bundle。该Bundle使用模型类似于Doctrien ORM,除了关系(正在使用N1QL Join进行工作)。对于key view的数据检索,正在使用N1QL和索引(对于快速搜索是必须的)

安装

打开命令行,进入您的项目目录,然后执行以下命令以下载此Bundle的最新版本

composer require fredpalas/couchbase-bundle
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...        
        new Apperturedev\CouchbaseBundle\CouchbaseBundle(),
    );
}
# app/config/config.yml
couchbase:
    url: <couchbase.url>
    buckets:
        default: #dafult bucket
            bucket_name: <bucket name>         

需求

JMS Serializer

文档

//in action throw container

public function indexAction()
{
    /** @var Apperturedev\CouchbaseBundle\Classes\CouchbaseORM $couchbase editor Helper */
    $couchbase = $this->get('couchbase');
    
    $entity = New Entity();
    // do anything
    
    // save
    $couchbase->save($entity);
    
    $entity->getId();  // Will set the id Automatic
    
    $repository = $couchbase->getRepository('Bundle:Entity');
    // get data
    $entity1 = $repository->getById(1);
    
    /** For Run Couchbase View you need to run bin/console couchbase:generate:view Bundle:Entity */
    /** Fixing a bug for moving old version class */
    // country example           
    $query = $repository->get('country');
    $query->key('Spain')->order(\CouchbaseViewQuery::ORDER_ASCENDING)->limit(6);

    // Will return a array if more than 1 or the object if is 1
    $country = $repository->execute($query);
}