dnocode/yii2-awsddb

Amazon DynamoDB ActiveRecord for Yii 框架

安装: 110

依赖者: 0

建议者: 0

安全: 0

星星: 3

关注者: 3

分支: 3

开放问题: 3

类型:yii2-extension

v1.0.2 2015-01-08 10:56 UTC

This package is not auto-updated.

Last update: 2024-09-24 16:20:29 UTC


README

此扩展提供了对 Amazon DynamoDB 的 activeRecord 支持

return [ //.... 'components' => [ ddb' => [ "class"=>'dnocode\awsddb\ar\Connection', 'base_url'=>"https://:8000 [OPTIONAL ONLY FOR DYNAMO LOCAL]", 'key' => 'AMAZONKEY', 'secret' => 'AMAZONSECRET', 'region' => 'eu-west-1' ], ] ];

安装

添加到 composer 依赖项

"dnocode/yii2-awsddb": "*"

使用

如何定义模型

class Element {

   public $name;
   public $surname;
   public $sex;
   public $uid;

    /**hash and range**/
    public static function primaryKey(){ return ["uid"];}

    public function rules(){    return [[['uid'], 'required']];}
}

#put

$e=new Element();
$e->name
$e->name="nerd";
$e->surname="iam";
$e->sex="no_nerd_i_said";
$e->uid="ciao";
$e->save();

#find and update

 $element=Element::find()->where(["uid"=>"ciao"])  ->one();
 $element->surname="update";
 $consumer->save();

#delete and update

 $element=Element::find()->where(["uid"=>"ciao"])  ->one();
 $element->delete();
 Element::deleteAll(["uid"=>"ciao"]);

使用 where 查找

  $element=Element::find()->
          where(["surname"=>"iam"])
          ->one();

通过哈希键查找对象

the active record will use
 get operation 4  performance*/

```
$element=Element::find()->
        andWhere("uid")
        ->eq("ciao")
        ->all();*/
 ```

在非主键属性上执行查找

    will be execute a scan operation with filter on that attribute

```
$element=Element::find()->
        andwhere("surname")->eq("prova")
        ->all();
```

比较多个值属性

```
 $element=Element::orWhere("name")->in(["name1","name2"])
 ->all();
```

#TODO

  1. 支持事务的批量操作
  2. 支持关系
  3. 支持超过 1MB 的查询迭代器