定制 hema/mongo_transaction 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

hema/mongo_transaction

最新稳定版本:1.5

Composer 安装命令:

composer require hema/mongo_transaction

包简介

adding transaction feature to jenssegers/mongodb

README 文档

README

Laravel Mongo Transaction

How to Install:

Assuming you have already installed composer require jenssegers/mongodb and configured it fully according to the documentation (https://packagist.org/packages/jenssegers/mongodb), now run this to install mongo-transactions:

composer require hema/mongo_transaction

In your Model Or BaseModel Use The Flowing Model :

use Hema\MongoTransaction\Transactions\Eloquent\Model

Instead of Jenssegers Model

use use Jenssegers\Mongodb\Eloquent\Model 

Note :

  • this package created for specific business needs. so, it's may not fit your needs 100%. but you still can fork it and extend or modify it.

  • you've to enable replica set in Mongo.

~$ sudo mongod --replSet "rs0" 

and then run mongo

~$ sudo mongo 

now you can use transaction this way :

use Hema\MongoTransaction\Transactions\Transaction
* Transaction::start();

// ........ A bunch of other db operations

* Transaction::commit();

// ........ commit when success


* Transaction::rollback();

// ........ Or rollback when error occure

Now You Can Use These Methods with transaction

* create();
* insert();
* update();
* delete();
* forceDelete(); 
* restore()
* increment();
* decrement();

* trash(); //custome method for soft-delete
* remove(); //custome method for hard-delete

Example :

    Transaction::start();

  try {
 	User::insert($some_data);

  	Profile::insert($some_data);

        Transaction::commit();

        return 'done';

   } catch (\Exception $e) {

        Transaction::rollback();

  	return $e->getMessage();
   }

统计信息

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

GitHub 信息

  • Stars: 4
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-12-10

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固