MongoDB-native
(require (planet dabag/mongodb-native:1:0)) |
Built on top of the MongoDB package (also provides all its functions and plus mongo-connection? which is renamed duplicate of mongo?.
This package contains functions created to facilitate interaction with database.
(connect-to-mongo) |
(mongo-dbs) |
(mongo-use-db "pltexample") |
(mongo-collections) |
(mongo-use-collection "first") |
(mongo-find) |
(mongo-save '((a . 123) (|b c d| . "asd"))) |
(mongo-save (list (cons 'a 123) (cons '|b c d| "asd"))) |
(mongo-save '((id . 1))) |
(mongo-save (list (list 'id (cons 'a 1) (cons 'b 2)) (cons 'b 1))) |
(mongo-find) |
(mongo-find '((a . 123))) |
(mongo-findOne '((a . 123))) |
(mongo-update '((id . 1)) '((c . 3))) |
(mongo-find-by-id 1) |
(mongo-update '((id . 1)) '()) |
(mongo-find-by-id 1) |
(let ((object (make-hash))) |
(hash-set! object 'b 2) |
(hash-set! object 'c 4) |
(mongo-save object)) |
(let ((object (make-hash))) |
(hash-set! object 'b 2) |
(mongo-findOne object)) |
(mongo-update '((b . 2)) '(($inc (c . 3)))) |
(mongo-findOne '((b . 2))) |
(let ((object (mongo-findOne '((b . 2))))) |
(hash-set! object 'c |
(add1 (hash-ref object 'c))) |
(mongo-save object)) |
(mongo-find) |
(mongo-connect #:dbname "pltexample" #:collection "first") |
(mongo-dbs) |
(mongo-collections) |