https://github.com/ktakashi/r6rs-mongodb
Portable R6RS MongoDB binding
https://github.com/ktakashi/r6rs-mongodb
mongodb mongodb-client r6rs r6rs-scheme scheme
Last synced: about 1 month ago
JSON representation
Portable R6RS MongoDB binding
- Host: GitHub
- URL: https://github.com/ktakashi/r6rs-mongodb
- Owner: ktakashi
- License: bsd-2-clause
- Created: 2018-05-18T09:26:50.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-04-23T08:04:33.000Z (about 6 years ago)
- Last Synced: 2024-10-06T01:21:41.762Z (7 months ago)
- Topics: mongodb, mongodb-client, r6rs, r6rs-scheme, scheme
- Language: Scheme
- Homepage:
- Size: 155 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: COPYING
Awesome Lists containing this project
README
# MongoDB binding for R6RS
[](https://travis-ci.org/ktakashi/r6rs-mongodb)
This is an R6RS Scheme implementation of MongoDB wire protocol.
# How to use
The most of users should use only `(mongodb)` library which contains
MongoDB connection, database and CRUD operations. The following piece of
code shows the simple CRUD operation with this library:```scheme
(import (rnrs)
(mongodb))(define connection
(open-mongodb-connection! (make-mongodb-connection "localhost")))
(define database (make-mongodb-database connection "test"))(define collection "testCollection")
(mongodb-database-insert database collection
'#(
(("id" 1) ("name" "R6RS MongoDB library") ("lang" "Scheme")))
)
(mongodb-database-upsert database collection
'(("name" "R7RS PostgreSQL library"))
'(("$set"
(("id" 2) ("name" "R7RS PostgreSQL library") ("lang" "Scheme")))))(mongodb-database-update database collection
'(("id" 1))
'(("$set" (("lang" "R6RS Scheme")))))
(mongodb-database-update-all database collection
'(("id" (("$gt" 0))))
'(("$set" (("comment" "Portable Scheme library")))))(mongodb-query-for-each (lambda (doc) (write doc) (newline))
(mongodb-database-query database collection '()))(mongodb-database-delete-all database collection '())
(display
(mongodb-query-result-documents
(mongodb-database-query database collection '()))) (newline)(close-mongodb-connection! connection)
```
The above code prints more or less like this output (formatted for readability):
```
(("_id" (object-id "5b1110aa9614bc720de985b6"))
("id" 1)
("name" "R6RS MongoDB library")
("lang" "R6RS Scheme")
("comment" "Portable Scheme library"))
(("_id" (object-id "5b1110aa9614bc720de985b8"))
("id" 2)
("name" "R7RS PostgreSQL library")
("lang" "Scheme")
("comment" "Portable Scheme library"))
#()
```# Documents
- [Users' reference](doc/UsersReference.md)
- [SBSON](doc/SBSON.md)
- [Developers' reference](doc/DevelopersReference.md)# Supporting implementations
The following implementations are tested:
- Sagittarius 0.9.2
- Larceny 1.3
- Chez Scheme v9.5## For Chez Scheme
Chez Scheme requires the shared object made of
`src/mongodb/net/tcp/chez.c` file which provides simple socket
interface for Chez Scheme. The file is written C however, it can only
be compiled on POSIX environment (only tested on Ubuntu). The build
command is the following:```shell
$ gcc -fPIC -shared -O3 src/mongodb/net/tcp/chez.c \
-o src/mongodb/net/tcp/chez.so
```The shared file name must also be the one specified above (even on OS X).
If you have better solution, please send a PR.
# Extension libraries
There're implementation dependent extension libraries as well. These are
located under the [`contrib`](contrib) directory.# Copyright and lincence
Copyright 2018 Takashi Kato. Code released under the BSD-style license.
See [COPYING](COPYING).