Re: [expath] MongoDB Module: Working Draft

Hi Christian,
I would like to make a few suggestions concerning the new MongoDB module: one major, several minor.
index management===============
First of all, I feel we need two functions for creating and dropping indexes, something similar to this:
mongodb:createIndex($client-id as xs:string, $database as xs:string, $collection as xs:string, 
$indexDescriptor as map(*), $options as map(*)) as map(*)

mongodb:dropIndex($client-id as xs:string, $database as xs:string, $collection as xs:string, 
$indexDescriptor as map(*)) as map(*)

[The returned map is meant to report the success.]
Of course, an index info function would also be useful, like this:mongodb:getIndexes($client-id as xs:string, $database as xs:string, $collection as xs:string) as map(*)

mongodb:update / return value
========================When an 'update' call uses the "upsert" option, it may create a new document whose _id should be returned. Therefore I suggest that the return value of mongodb:update should not be empty-sequence(), but either xs:string? or, better, a map containing the values supplied by the 'WriteResult' object when using the mongo shell, for instance:WriteResult({ "nMatched" : 25, "nUpserted" : 0, "nModified" : 24 })

mongodb:find / options
==================The spec says about "fields": 
   "Restricts the returned fields. The file _id will always be returned."
However, supposing that the XQuery function is equivalent to db.collection.find(), the _id field can be suppressed by the "fields" entry "_id: 0", which can be combined with inclusive and exclusive field selection, alike. I suppose this issue concerns only the spec text, not the intended functionality?
~ ~ ~
Finally an editorial suggestion. Later, the spec might perhaps for each mongodb function specify the equivalence of functionality provided by the function on one hand, and a well-defined MongoDB operation on the other hand: for example the equivalence between mongodb:find and db.collection.find, including the alignment of function parameters and operation parameters. Having established such an equivalence, the normative semantics could be reduced to "providing the result/effect one would have obtained/produced by using the equivalent MongoDB operation"; of course the spec should continue to provide a brief description, but it would be non-normative.
Cheers,Hans-Jürgen

Received on Sunday, 8 March 2015 22:46:47 UTC