Now on to MongoDB. I began playing with Racket MongoDB "Quickstart" example. It went well so I changed a few things, and I checked everything through the mongo shell. Then I began to play around with more Racket commands, and "mongo-db-collections" always returned an empty list, even when the mongo shell's "show collections" command returned a (correct) non-empty list. I finally tracked the problem down to a change in the MongoDB API since version 3.0 (my MongoDB is 3.4).
Instead of "<database>.system.namespaces" they now use "listCollections". So I first tried to change "~a.system.namespaces" to "listCollections" in (a copy of ) "... mongodb/basic/driver.rkt" without success. Then I noticed that the "mongo-list-databases" command used a "listDatabases" call to MongoDB. Thinking there might be a reason for the similar names, I tried modeling a new "mongo-db-collections" after "mongo-list-databases". After much wailing and gnashing of teeth (and learning some Racket in the process) I came up with what I hope is a suitable fix:
(provide/contract
[mongo-db-collections (mongo-db? . -> . (listof string?))])
(define (mongo-db-collections d)
(for/list ([c (in-vector (mongo-list-collections d))] #:when (hash-has-key? c 'idIndex))
(hash-ref c 'name)))
The "#:when" clause is because MongoDB slipped a "system.profile" collection into the response. It is distinguished from the ones for the database I was asking about by not having an 'idIndex field.
... and the helper function:
(define (mongo-list-collections d)
(hash-ref (hash-ref (mongo-db-execute-command! d `([listCollections . 1]))
'cursor) 'firstBatch))
The two "hash-ref"s are to peel the desired info out of the json (bson) returned by MongoDB.
I'm working on some routines to search the MongoDB and pretty-print the results of the search, but they are not very robust right now. If anyone is interested, or has more mature code for these tasks, let me know.