Skip to content
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

Making an EXPath module? #35

Open
ChristianGruen opened this issue Feb 24, 2015 · 4 comments
Open

Making an EXPath module? #35

ChristianGruen opened this issue Feb 24, 2015 · 4 comments
Assignees

Comments

@ChristianGruen
Copy link

Hi Dannes, I've just discovered your MongoDB module for eXist-db. We've done a similar module recently, based on XQuery maps and arrays; maybe we can join forces and make an EXPath module out of it? Would you be interested?

@ChristianGruen
Copy link
Author

@dizzzz dizzzz self-assigned this Feb 24, 2015
@dizzzz
Copy link
Collaborator

dizzzz commented Feb 24, 2015

Hi Christian,

yes I would be certainly be interested in aligning the works, and join forces; I am actually developing a Couchbase driver as well, so your message pos in on the right moment :-)

@ChristianGruen
Copy link
Author

Here are two simple examples of our MongoDB connector (which was inspired by the Java driver. It looks pretty similar to your approach:

(: Example 1: List all database entries. :)
import module namespace mongo = 'http://basex.org/modules/mongodb';

(: Could potentially be extended to multiple server addresses :)
let $mongo-id := mongo:connect('localhost', 27017)
return (
  for $db-id in mongo:dbs($mongo-id)
  for $coll-id in mongo:collections($db-id)
  return mongo:find($coll-id),
  (: optional: connection will automatically be closed after query execution :)
  mongo:close($mongo-id)
)

(: Possible result: :)
map { "_id": 1, "name" : "eXist-db" },
map { "_id": 2, "name" : "BaseX" },
map { "_id": 3, "name" : "Saxon" },
map { "_id": 4, "name" : "Zorba" },
map { "_id": 5, "name" : "Qizx" }
(: Example 2: Find specified collection entry. :)
import module namespace mongo = 'http://basex.org/modules/mongodb';

let $mongo := mongo:connect('localhost')
let $db := mongo:db($mongo, 'database')
let $coll := mongo:collection($db, 'collection')
return mongo:find($coll, map { '_id': 1 })

We have no critical applications for this module so far, and you said you are already working on the second version, so we could further align it with your function signatures.

@dizzzz
Copy link
Collaborator

dizzzz commented Feb 24, 2015

Ok I'll dive into it; most of the signatures are documented in the wiki, and have xquery test: https://github.com/dizzzz/Mongrel/tree/develop/java/test/src/org/exist/mongodb/test/db ; the tests marked with _xq31 indicate xquery31 compatible tests....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants