4 ORM Operations
(require (planet jaymccarthy/mongodb:1:2/orm/main)) |
An "ORM" style API is built on the basic Mongo operations.
4.1 Dictionaries
(require (planet jaymccarthy/mongodb:1:2/orm/dict)) |
A Mongo dictionary is a dictionary backed by Mongo.
(create-mongo-dict col) → mongo-dict? |
col : string? |
(mongo-dict-query col query) → (sequenceof mongo-dict?) |
col : string? |
query : bson-document/c |
(current-mongo-db) → (or/c false/c mongo-db?) |
(current-mongo-db db) → void? |
db : (or/c false/c mongo-db?) |
(mongo-dict-count md) → exact-nonnegative-integer? |
md : mongo-dict? |
4.2 Structures
(require (planet jaymccarthy/mongodb:1:2/orm/struct)) |
define-mongo-struct is a macro to create some convenience functions for Mongo dictionaries.
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Every field implicitly has the #:ref option. Every mutable field implicitly has the #:set! option. Every immutable field implicitly has the #:required option. It is an error for an immutable field to have any options other than #:required and #:ref, which are both implicit.
make-struct takes one keyword argument per field. If the field does not have the #:required option, the argument is optional and the instance will not contain a value for the field. make-struct returns a mongo-dict?.
If a field has the #:ref option, then struct-field is defined. It is implemented with mongo-dict-ref.
If a field has the #:set option, then set-struct-field! is defined. It is implemented with mongo-dict-set!.
If a field has the #:inc option, then inc-struct-field! is defined. It is implemented with mongo-dict-inc!.
If a field has the #:null option, then null-struct-field! is defined. It is implemented with mongo-dict-remove!.
If a field has the #:push option, then push-struct-field! is defined. It is implemented with mongo-dict-push!.
If a field has the #:append option, then append-struct-field! is defined. It is implemented with mongo-dict-append!.
If a field has the #:set-add option, then set-add-struct-field! is defined. It is implemented with mongo-dict-set-add!.
If a field has the #:set-add* option, then set-add*-struct-field! is defined. It is implemented with mongo-dict-set-add*!.
If a field has the #:pop option, then pop-struct-field! is defined. It is implemented with mongo-dict-pop!.
If a field has the #:shift option, then shift-struct-field! is defined. It is implemented with mongo-dict-shift!.
If a field has the #:pull option, then pull-struct-field! is defined. It is implemented with mongo-dict-pull!.
If a field has the #:pull* option, then pull*-struct-field! is defined. It is implemented with mongo-dict-pull*!.