PHP Class yii2tech\balance\ManagerMongoDb

This storage requires yiisoft/yii2-mongodb extension installed. Configuration example: php return [ 'components' => [ 'balanceManager' => [ 'class' => 'yii2tech\balance\ManagerMongoDb', 'accountCollection' => 'BalanceAccount', 'transactionCollection' => 'BalanceTransaction', 'accountBalanceAttribute' => 'balance', 'extraAccountLinkAttribute' => 'extraAccountId', ], ], ... ]; Since MongoDB is schema-less this manager allows to save any transaction data as plain record attribute, which will be searchable. However MongoDB does not support transactions, thus usage of this manager may be risk prone.
See also: Manager
Since: 1.0
Author: Paul Klimov ([email protected])
Inheritance: extends Manager
Mostrar archivo Open project: yii2tech/balance

Public Properties

Property Type Description
$accountCollection name of the MongoDB collection, which should store account records.
$db the MongoDB connection object or the application component ID of the MongoDB connection. After the ManagerMongoDb object is created, if you want to change this property, you should only assign it with a MongoDB connection object.
$transactionCollection name of the MongoDB collection, which should store transaction records.

Public Methods

Method Description
calculateBalance ( $account )
init ( )

Protected Methods

Method Description
createAccount ( $attributes )
createTransaction ( $attributes )
findAccountId ( $attributes )
findTransaction ( $id )
incrementAccountBalance ( $accountId, $amount )

Method Details

calculateBalance() public method

public calculateBalance ( $account )

createAccount() protected method

protected createAccount ( $attributes )

createTransaction() protected method

protected createTransaction ( $attributes )

findAccountId() protected method

protected findAccountId ( $attributes )

findTransaction() protected method

protected findTransaction ( $id )

incrementAccountBalance() protected method

protected incrementAccountBalance ( $accountId, $amount )

init() public method

public init ( )

Property Details

$accountCollection public_oe property

name of the MongoDB collection, which should store account records.
public $accountCollection

$db public_oe property

the MongoDB connection object or the application component ID of the MongoDB connection. After the ManagerMongoDb object is created, if you want to change this property, you should only assign it with a MongoDB connection object.
public $db

$transactionCollection public_oe property

name of the MongoDB collection, which should store transaction records.
public $transactionCollection