MongoHelper
Can be used by any class which accesses MongoDB.
Instance Methods
| Returns | Signature and Description |
|---|---|
Ta | Makes sure a document isn't null. |
UTCDateTime | now()Gets the current time. |
?UTCDateTime | toDate()Tries to parse a date. |
ObjectID | toId()Transforms a literal into a MongoDB ObjectId. |
ConstVector<ObjectID> | toIds()Transforms literals into MongoDB ObjectIds. |
Method Details
ensure
ensure<Ta>(mixed $id, ?Ta $document)Makes sure a document isn't null.
| Name | Type | Description |
|---|---|---|
$id | mixed | The document identifier, either a |
$document | ?Ta | The document to check |
| Type | Description |
|---|---|
Ta | Returns |
| Type | Conditions |
|---|---|
Unretrievable | if the document is null |
now
now()Gets the current time.
| Type | Description |
|---|---|
UTCDateTime | The current time |
toDate
toDate(mixed $date)Tries to parse a date.
| Name | Type | Description |
|---|---|---|
$date | mixed | The possible string date value, a string, a |
| Type | Description |
|---|---|
?UTCDateTime | The MongoDB datetime or null |
toId
toId(mixed $id)Transforms a literal into a MongoDB ObjectId.
| Name | Type | Description |
|---|---|---|
$id | mixed | If it's an |
| Type | Description |
|---|---|
ObjectID | The ObjectID |
toIds
toIds(ConstVector<mixed> $ids)Transforms literals into MongoDB ObjectIds.
| Name | Type | Description |
|---|---|---|
$ids | ConstVector<mixed> | Goes through each entry, converts to |
| Type | Description |
|---|---|
ConstVector<ObjectID> | The ObjectIDs |