Skip to content

Split and modify CRUD examples #1

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

Merged
merged 3 commits into from
May 13, 2014
Merged

Split and modify CRUD examples #1

merged 3 commits into from
May 13, 2014

Conversation

jmikola
Copy link
Member

@jmikola jmikola commented May 13, 2014

No description provided.


$mm = new \MongoDB\Manager("mongodb://server1,server2/?replicaSet=FOOBAR");

$results = $mm->executeWrite("db.collection", $batch, $writeOptions);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than InsertBatch telling us that the operations are inserts (by its class name), I don't see why we shouldn't just pass in an array of operations. This would mean we'd have specific methods like executeInsert(), which I think is fine. In the C code, it means there's no need to check the class and then branch off internally to the appropriate write method in libmongoc. Also, being able to pass an array of operations (e.g. documents to insert or the update arguments) in one shot addresses @derickr's concern about having a simple interface.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having a classname makes it easier and cleaner to validate the actual operations.
Having to validate enormous array all the time is both complex and not something you want to have multiple branches of in one method.

Allow individual classes to provide their own validation and then simply be typehinted simplifies the entire chain of events and allows us to keep small pieces of selfcontained code.

Having an executeInsert(array($document1, $document2)); is begging for validation issues and "whops, I did executeInsert($document)"

Providing a \MongoDB\Manager\CRUD->insertOne($document); is a trivial wrapper though we could also provide as part of the extension as a simplified helper API....

$query = new \MongoDB\Query($criteria, $selector);
$query
->setOrderBy(array('name' => 1))
->setComment('More special stuff')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

http://docs.mongodb.org/manual/reference/operator/query-modifier/#operators

What do we do with all the other operators?
$query->setOperator($name, $value) ? feels a tinybit weird...

@bjori
Copy link
Contributor

bjori commented May 13, 2014

looks good.
There is something a little bit /off/ about the Query object stilll....

bjori added a commit that referenced this pull request May 13, 2014
Split and modify CRUD examples
@bjori bjori merged commit ba74b89 into master May 13, 2014
@jmikola jmikola deleted the split-crud branch May 14, 2014 04:07
@JoyCood JoyCood mentioned this pull request Apr 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants