txmongo icon indicating copy to clipboard operation
txmongo copied to clipboard

Check, fix and update examples

Open IlyaSkriblovsky opened this issue 7 years ago • 8 comments

Unfortunately, many of our examples are of bad quality.

  • Some examples simply not working due to errors in the example code
  • Some are confusingly overengineered
  • Some treat Connection and ConnectionPool like Deferreds which may confuse readers
  • Almost all of them use the old CRUD API
  • Many are py3-incompatible

We need short, consice, practical (and working!) examples to simplify onboarding of new users!

(see #215)

IlyaSkriblovsky avatar Sep 11 '17 07:09 IlyaSkriblovsky

Yes yes yes! I would like to help with this. Out of curiosity, I went over to the pymongo project to see if they had anything, but they didn't. Do you have a strategy or layout in mind to set these up? It might be helpful if the various examples followed some sort of template to make them easier to navigate and understand.

trenton42 avatar Sep 11 '17 13:09 trenton42

I'm not sure what common template do you mean? I personally prefer very short and concise examples mainly to help with bootstrapping. Longer real-life examples are optional for me.

IlyaSkriblovsky avatar Sep 11 '17 15:09 IlyaSkriblovsky

Sorry I wasn't clear. I was mainly just thinking about organizing the examples so they could be run the same way and their code was laid out similarly so it would be easier to follow from one example to the next.

trenton42 avatar Sep 11 '17 15:09 trenton42

Extensive list of possible examples:

  • [ ] Single connection, Connection pool
  • [ ] Connecting by host/port, by url, with url options
  • [ ] Authentication
  • [ ] SSL
  • [ ] insert, update, replace, remove
  • [ ] find, find_one, sorting, iterating with cursor, find_one_and_*
  • [ ] Misc collection methods: count, distinct, drop, create_index
  • [ ] Misc database methods: command, create_collection, collection_names
  • [ ] Bulk ops
  • [ ] Write concerns & Codec options
  • [ ] GridFS
  • [ ] Aggregation
  • [ ] Callback-style vs. inlineCallbacks-style
  • [ ] A couple of real-life examples: webapp, standalone command line utility
  • [ ] May be some useful real-life tricks: optimistic locking, incrementing integer counter, ...

IlyaSkriblovsky avatar Sep 11 '17 16:09 IlyaSkriblovsky

I hope most of examples won't contain much of boilerplate code, so the common template might only contain an assertion that all examples connect to localhost:27017/test database. May be I'm missing something.

IlyaSkriblovsky avatar Sep 11 '17 16:09 IlyaSkriblovsky

That is good 👍 I will have a go at writing some examples and send over a PR

trenton42 avatar Sep 11 '17 16:09 trenton42

Thanks! I will try to find some time for this too. Please ping me with the topics you are working on when you start to avoid duplicating efforts.

IlyaSkriblovsky avatar Sep 11 '17 16:09 IlyaSkriblovsky

started to write some connection examples in #217

IlyaSkriblovsky avatar Sep 14 '17 11:09 IlyaSkriblovsky