-
Notifications
You must be signed in to change notification settings - Fork 266
PHPLIB-70: Resource CRUD prototypes #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
786471a
0c0d334
4b0d5ad
b51e1b3
b6a120e
495e46d
448800b
ea6da09
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,6 +64,73 @@ public function __construct(Manager $manager, $ns, WriteConcern $wc = null, Read | |
list($this->dbname, $this->collname) = explode(".", $ns, 2); | ||
} | ||
|
||
/** | ||
* Create a single index in the collection. | ||
* | ||
* @see http://docs.mongodb.org/manual/reference/command/createIndexes/ | ||
* @see http://docs.mongodb.org/manual/reference/method/db.collection.createIndex/ | ||
* @param array|object $keys | ||
* @param array $options | ||
* @return string The name of the created index | ||
*/ | ||
public function createIndex($keys, array $options = array()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the usecase of having it object as apposed of useful array? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The user should be able to specify a BSON object. I was thinking of the case where they want to index the |
||
{ | ||
// TODO | ||
} | ||
|
||
/** | ||
* Create multiple indexes in the collection. | ||
* | ||
* TODO: decide if $models should be an array of associative arrays, using | ||
* createIndex()'s parameter names as keys, or tuples, using parameters in | ||
* order (e.g. [keys, options]). | ||
* | ||
* @see http://docs.mongodb.org/manual/reference/command/createIndexes/ | ||
* @see http://docs.mongodb.org/manual/reference/method/db.collection.createIndex/ | ||
* @param array $models | ||
* @return string[] The names of the created indexes | ||
*/ | ||
public function createIndexes(array $models) | ||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It needs to throw DuplicateIndex exception or something like that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is only a problem if the model or name match an existing index with different options, correct? Sounds like something we should document in the spec, too. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no I mean, the proto is missing @throws declaration that it can throw various exceptions, such as duplicateindex (should we have explicit exception for that?), or other Exceptions |
||
// TODO | ||
} | ||
|
||
/** | ||
* Drop this collection. | ||
* | ||
* @return Result | ||
*/ | ||
public function drop() | ||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What happens to this instance after calling drop? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. exec('halt -f');
exit(0); There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But really, we don't need to do anything. A Collection instance doesn't require anything to actually exist in the database, so there's nothing to clean up in PHP. If we started doing stuff like caching index enumeration class, perhaps, but not now. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
// TODO | ||
} | ||
|
||
/** | ||
* Drop a single index in the collection. | ||
* | ||
* @see http://docs.mongodb.org/manual/reference/command/dropIndexes/ | ||
* @see http://docs.mongodb.org/manual/reference/method/db.collection.dropIndex/ | ||
* @param string $indexName | ||
* @return Result | ||
* @throws InvalidArgumentException if "*" is specified | ||
*/ | ||
public function dropIndex($indexName) | ||
{ | ||
// TODO | ||
} | ||
|
||
/** | ||
* Drop all indexes in the collection. | ||
* | ||
* @see http://docs.mongodb.org/manual/reference/command/dropIndexes/ | ||
* @see http://docs.mongodb.org/manual/reference/method/db.collection.dropIndexes/ | ||
* @return Result | ||
*/ | ||
public function dropIndexes() | ||
{ | ||
// TODO | ||
} | ||
|
||
/** | ||
* Performs a find (query) on the collection | ||
* | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the Database object have __toString() method and this code explicitly do (string)$databaseName ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we did that and allowed the argument to be either a string or a Database instance, would we get into trouble with
dropCollection()
? I would expect a Collection's__toString()
method to return its full namespace, as we do in the 1.x driver. I'd rather not invite the inconsistency.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The proto should definetly not be string|Database, it should be string - but if it does (string) casting inside the method it implicitly allows the Database object to work seamlessly.
as for dropCollection() returning fully qualified namespace...... mmmmh.....