-
Type: New Feature
-
Resolution: Won't Fix
-
Priority: Unknown
-
None
-
Affects Version/s: None
-
Component/s: Collection Management
-
None
Proposition to add a method Collection::create(array $option) as a helper for Database::createCollection() for consistency with Collection::drop(array $options)
Usage:
// Existing methods $db->createCollection('items', ['capped' => true, 'size' => 8192]); $db->dropCollection('items'); $db->items->drop(); // New method $db->items->create(['capped' => true, 'size' => 8192]);
Historically, collections are created from the parent database object. The driver API is based on the MongoDB shell, which only has a db.createCollection() method. The drop() methods are a different case, since the shell provides drop methods on both databases and collections (instead of requiring you to call client.dropDatabase or database.dropCollection). There's no technical reason we can't duplicate a create helper on the collection object.
- is related to
-
DRIVERS-2118 Create collection and database management specifications
- Backlog