Giter VIP home page Giter VIP logo

laravel-mongodb-transactions's Introduction

About coolsam/laravel-mongodb-transactions

Lately, Jensseger's laravel-mongodb package has become very popular among Laravel developers such as me who want to leverage the power of NoSQL databases, specifically mongodb. I must say laravel-mongodb is perfect for ORM and Eloquent query building. However, one feature that lacks is the ability to perform multi-document transactions while inserting or updating data in the DB. I know mongoDB 4.x supports multi-document transactions but there is yet to exist a proper documentation on how this can be implemented in php, especially how it can be integrated to Jensseger's package. This package therefore extends Jenssegers/laravel-mongodb with support to transactions.

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 laravel-mongodb-transactions:

composer require coolsam/laravel-mongodb-transactions #####Configuration Then add the following service provider in config/app.php (Package auto discover might take care of this in Laravel ^5.5):

Coolsam\Transactions\MongodbTransactionsServiceProvider::class
Usage
$uuid = 'UUID';

Model::openTransactions($uuid);

AccountModel::where('a_uid', 123)->increment('a_money', 100);
// ........ A bunch of other db operations

Model::rollback($uuid); 

Or go ahead and commit the transaction if satisfied with it.

$uuid = 'UUID';

Model::openTransactions($uuid);

AccountModel::where('a_uid', 123)->increment('a_money', 100);
// ........ A bunch of other db operations

Model::commit($uuid); 

laravel-mongodb-transactions's People

Contributors

coolsam726 avatar viest avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

laravel-mongodb-transactions's Issues

Unable to download package

[InvalidArgumentException]
Could not find a matching version of package coolsam/laravel-mongodb-transactions. Check the package spelling, your version constraint and that the packa
ge is available in a stability which matches your minimum-stability (dev).

require [--dev] [--prefer-source] [--prefer-dist] [--no-progress] [--no-suggest] [--no-update] [--no-scripts] [--update-no-dev] [--update-with-dependencies] [--update-with-all-dependencies] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--] []...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.