Closed sergeyklay closed 11 years ago
I think you answered your own question..
But I don't quite understand how do call Mongo_Database::__get($name)
and get a collection created with arbitrary options, e.g. as described above.
It turns out must first create a collection, and then get it?
In order to create a collectionneed to first determine whether it exists or not. I propose to put the following code into the class:
/**
* Checks for the $collection in the currently referenced database
*
* @param string $collection Collection name
* @return boolean
*/
public function exists($collection)
{
$result = $this->db()->system->namespaces->findOne(
array('name'=>"{$this->_config['database']}." . $collection)
);
return ( ! is_null($result));
}
or something like that
For adition information please see http://docs.mongodb.org/manual/reference/system-collections/
P.S. I am sorry for this syntax I'm not sure that at this stage the database name can be obtained easier
Hi!
How can I get new collection by
Mongo_Database::__get($name)
with custom options?Obviously, when creating the collection we can point explicitly:
Based on the official documentation of the parameters have the following meaning:
capped
size
max
autoIndexId
But I frankly do not yet quite understand how to use
Mongo_Database::__get($name)
to get (create) the new collection with the specified parameters where the object is an instance of theMongo_Colleaction
class...Best regards,