\Localgod\Tick\StorageMongoStorage

Tick mongo storage implementation

MongoDB (from "humongous") is a scalable, high-performance, open source, document-oriented database.

Summary

Methods
Properties
Constants
__construct()
getConnection()
get()
insert()
update()
remove()
exists()
count()
closeConnection()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
criteria()
convertDateTime()
$connection
N/A

Properties

$connection

$connection : \MongoDB

Database connection

Type

\MongoDB

Methods

__construct()

__construct(\MongoDB  $connection) 

Set the database connection

Parameters

\MongoDB $connection

Database connection

getConnection()

getConnection() : \Localgod\Tick\Storage\Mongo

Get storage connection

Returns

\Localgod\Tick\Storage\Mongo —

A Mongo instance

get()

get(string  $collection, array  $fields, array  $criterias, array  $order = array(), boolean  $direction = true, integer  $limit = null, integer  $offset = null) : array

Get entities in storage

Parameters

string $collection

Collection to search

array $fields

Properties to fetch

array $criterias

Criterias to search by

array $order

Order result

boolean $direction

Order direction

integer $limit

Limit result

integer $offset

Offset result

Throws

\RuntimeException

if the query failed

Returns

array —

Array with Associative arrays with fieldname=>value

insert()

insert(string  $collection, array  $data) : integer

Insert entity to storage

Parameters

string $collection

Collection to insert into

array $data

Associative array with fieldname=>value

Returns

integer —

Id of the object inserted

update()

update(string  $collection, array  $data, array  $criterias) : void

Update entity in storage

Parameters

string $collection

Collection to update

array $data

Associative array with fieldname=>value

array $criterias

Criteria of the object to update

remove()

remove(string  $collection, array  $criterias) : void

Remove entity from storage

Parameters

string $collection

Collection to search

array $criterias

Criteria of the object to remove

exists()

exists(string  $collection, array  $criterias) : boolean

Entity exists in storage

Parameters

string $collection

Collection to search

array $criterias

Criteria of the object to check for

Returns

boolean —

if the entity exists

count()

count(string  $collection, array  $criterias) : integer

Count number of entities matching the criteria

Parameters

string $collection

Collection to search

array $criterias

Criteria of the object to check for

Returns

integer

closeConnection()

closeConnection() : void

Close storage connection

criteria()

criteria(array  $criterias) : array

Convert criteria to search arguments

Parameters

array $criterias

List of criterias

Returns

array

convertDateTime()

convertDateTime(\DateTime  $value = null) : \MongoDate

Convert DateTime object to a valid database representation

Parameters

\DateTime $value

Value to convert

Returns

\MongoDate —

null representation of a datetime value