MongoRepository
MMO\mongodb · 1 symbol · generated 5 Oct 2026
MongoRepository
MongoRepository.php:30Mongodb bridge
- Namespace
MMO\mongodb- Extends
- aRepository
Index
Constants1
AUTO_TEXT_INDEX
Properties7
backupFolder
- Type
- string
database
- Type
- string
handle
readonly- Type
- Manager
lock
- Type
- int
refs
- Type
- array
uri
readonly- Type
- string
url
- Type
- string
Methods40
autoTextIndexes($options)
MongoRepository.php:443backup($filename, $database, $shell, $remoteFile)
MongoRepository.php:97Backup database in a mongo specific archive
| $filename = null | null | string | (absolute or relative) an archive name |
| $database = null | null | string | |
| $shell = null | null | iShell | the shell to use for the execution of command |
| $remoteFile = null | null | string | (only if shell is remote) the remote file to save the archive into. if null, save it to tmp folder |
| returns | string | the filename of the archive |
collectionExists($name, $database)
MongoRepository.php:288Check if a collection exists
createCursor($collection, $filter, $options)
MongoRepository.php:540Create a mongo cursor from a simple filter.
| $collection | iCollection | string | |
| $filter | array | |
| $options = [] | array | |
| returns | Cursor |
createEntity($class, $data, $collection)
MongoRepository.php:172| $class | string | |
| $data = [] | array | |
| $collection = null | null | iCollection | |
| returns | iEntity |
createIndex($collection, $keys, $unique, $name, $options)
MongoRepository.php:394Create an index on one/multiple keys
createIndexes($collection, $indexes, $options)
MongoRepository.php:377Create multiple indexes
| $collection | iCollection | string | |
| $indexes | array | [{key: {xxx: 1|-1|text}, unique: bool, partialFilterExpression: {}, name: xxx} |
| $options = [] | array | |
| returns | void |
createPipelineCursor($collection, $pipeline, $options)
MongoRepository.php:571Create a mongo cursor from a pipeline.
| $collection | iCollection | string | |
| $pipeline | array | |
| $options = [] | array | |
| returns | Cursor |
createReadCommand($command, $options)
MongoRepository.php:549debugName()
MongoRepository.php:60| returns | string |
doResolution()
MongoRepository.php:243| returns | void |
dropAutoTextIndexes()
MongoRepository.php:475| returns | void |
dropCollection($collection, $opts)
MongoRepository.php:305| $collection | iCollection | string | |
| $opts = [] | array | |
| returns | bool |
dropDatabase($database, $opts)
MongoRepository.php:324dropIndexes($collection, $names)
MongoRepository.php:416| $collection | iCollection | string | |
| ...$names | string | |
| returns | void |
executeCustomQuery($collection, $filter, $options, $raw, $reload)
MongoRepository.php:665Execute a custom query and return the entities, resolving inner references
executeQuery($query, $opts)
MongoRepository.php:631Execute a query and return the entities, resolving inner references.
ExtractDatabaseFromName($filename)
staticMongoRepository.php:72getBackupFolder()
MongoRepository.php:64| returns | string |
getBackupName($date, $database)
MongoRepository.php:68getDatabases()
MongoRepository.php:332| returns | array |
getDistinct($collection, $key, $database)
MongoRepository.php:300getTemplateTextKeys($indexes, $schema, $template)
MongoRepository.php:427hasIndex($collection, $name)
MongoRepository.php:361| $collection | iCollection | string | |
| $name | string | |
| returns | bool |
isLockResolution()
MongoRepository.php:239| returns | bool |
listCollections($database)
MongoRepository.php:293listIndexes($collection)
MongoRepository.php:357| $collection | iCollection | string | |
| returns | array |
loadEntities($collection, $cursor, $reload)
MongoRepository.php:677Load entities from a cursor, resolving inner references
| $collection | iCollection | |
| $cursor | iterable | |
| $reload = false | bool | |
| returns | array |
lockResolution()
MongoRepository.php:225| returns | void |
loopIndexes($collection)
MongoRepository.php:344| $collection | iCollection | string | |
| returns | Generator |
onCommit($commit)
MongoRepository.php:710Save the entities of this commit that belong to this repository: one bulk write per collection. An entity removed leaves its collection; one created and removed before being saved is neither deleted nor inserted.
patch($database, $patch, $shell)
MongoRepository.php:81resolveReferences($data, $reload)
MongoRepository.php:185restore($filename, $database, $collections, $shell, $oldDatabase, $drop)
MongoRepository.php:127Restore backup from zip|tar archive
| $filename | DateTimeInterface | string | int | the filename of the archive. If not a string, use getBackupFolder and getBackupName to make it. |
| $database = null | null | string | |
| $collections = null | null | array | a list of collections to restore |
| $shell = null | null | iShell | the shell to use for the execution of command |
| $oldDatabase = null | null | string | the database's name that has been dump in the archive (you dump database 'test'(oldDatabase) but want to restore it in 'demo'(database).) |
| $drop = true | bool | |
| returns | void |
searchText($query, $text, $_hashes)
MongoRepository.php:482selectServer($mode)
MongoRepository.php:278https://www.mongodb.com/docs/manual/core/read-preference/ selon le tableau, pour les updates multi-doc il faut rester sur primary Peut-être faire les lectures sur les replicats et les écritures sur le primary ? Ca donnerait : --- pour le bulk return $this->handle->selectServer(new ReadPreference(ReadPreference::PRIMARY)); --- pour le find (voir si le temps de réplication peut impacter le métier) return $this->handle->selectServer(new ReadPreference(ReadPreference::SECONDARY_PREFERRED)); ou alors (à tester sur un cluster peut-être ?) return $this->handle->selectServer(new ReadPreference(ReadPreference::NEAREST));
uid()
MongoRepository.php:77| returns | string |
unlockResolution()
MongoRepository.php:229| returns | bool |
__construct($uri, $database, $collections)
MongoRepository.php:49__wakeup()
MongoRepository.php:55| returns | void |
Inherited members (23)
| Properties | Declared by | Description | |
|---|---|---|---|
collections | aRepository |
| Methods | Declared by | Description | |
|---|---|---|---|
addCollection($name, $collection) | aRepository | Add collection | |
createCollection($name, $entityClass, $collectionId) | aRepository | Create and register a plain Collection for entities of $entityClass. | |
createLog($type, $origin, $collection, $data, $filters, $sorts, $limit, $offset) | aRepository | Build (but not dispatch) a LogQuery entity describing a data-mutating operation, stored in the repository's LogQuery collection (if one is registered). | |
forceCommit($origin, $entities) | aRepository | ||
getCollection($name) | aRepository | ||
getCollectionByClass($entityClass, $allowChildClass) | aRepository | Find the collection whose entities are (an exact match, or optionally a subclass of) $entityClass. | |
getCollectionName($collection) | aRepository | ||
getCollections() | aRepository | ||
getEntities() | aRepository | ||
getIterator() | aRepository | \IteratorAggregate::getIterator -- iterates name => iCollection | |
hasCollection($collection) | aRepository | ||
hideLogData($collection, $data) | aRepository | What a repository logs is what it wrote (mmo.pdo's row, mmo.mongodb's document or its changes), hidden properties (ArrayProperty::isHidden) included, and a log is exported… | |
logDelete($origin, $collection, $data, $filters, $sorts, $limit, $offset) | aRepository | Log and dispatch a DELETE operation. | |
logInsert($origin, $collection, $data, $filters, $sorts, $limit, $offset) | aRepository | Log and dispatch an INSERT operation. | |
logStatus($origin, $collection, $data, $filters, $sorts, $limit, $offset) | aRepository | Log and dispatch a STATUS-change operation. | |
logUpdate($origin, $collection, $data, $filters, $sorts, $limit, $offset) | aRepository | Log and dispatch an UPDATE operation. | |
offsetExists($key) | aRepository | \ArrayAccess::offsetExists | |
offsetGet($key) | aRepository | \ArrayAccess::offsetGet | |
offsetSet($key, $value) | aRepository | \ArrayAccess::offsetSet -- equivalent to addCollection | |
offsetUnset($key) | aRepository | \ArrayAccess::offsetUnset | |
onFetch($event) | aRepository | Listener for Fetch: resolves a repository-uid/collection-id#id (or repository-uid/collection-id#id/nested/path for an embedded value) URL, what Ent… | |
setCollections($cols) | aRepository | Register a batch of collections at once, e.g. |