On this page:
top
up

4ORM OperationsπŸ”— i

An "ORM" style API is built on the basic Mongo operations.

4.1DictionariesπŸ”— i

A Mongo dictionary is a dictionary backed by Mongo.

procedure

( create-mongo-dict col)mongo-dict?

col:string?
Creates a new Mongo dictionary in the col collection of the (current-mongo-db ) database.

procedure

( mongo-dict-query colquery)(sequenceofmongo-dict? )

col:string?
Queries the collection and returns Mongo dictionaries.

procedure

( mongo-dict? x)boolean?

x:any/c
A test for Mongo dictionaries.
The database used in Mongo dictionary operations.

procedure

( mongo-dict-ref mdkey[fail])any/c

key:symbol?
Like dict-ref but for Mongo dictionaries, returns bson-null by default on errors or missing values.

procedure

( mongo-dict-set! mdkeyval)void

key:symbol?
val:any/c

procedure

( mongo-dict-remove! mdkey)void

key:symbol?

procedure

( mongo-dict-inc! mdkey[amt])void

key:symbol?
amt:number? =1
Increments key’s value by amt atomically.

procedure

( mongo-dict-push! mdkeyval)void

key:symbol?
val:any/c
Pushes a value onto the sequence atomically.

procedure

( mongo-dict-append! mdkeyvals)void

key:symbol?
vals:sequence?
Pushes a sequence of values onto the sequence atomically.

procedure

( mongo-dict-set-add! mdkeyval)void

key:symbol?
val:any/c
Adds a value to the sequence if it is not present atomically.

procedure

( mongo-dict-set-add*! mdkeyvals)void

key:symbol?
vals:sequence?
Adds a sequence of values to the sequence if they are not present atomically.

procedure

( mongo-dict-pop! mdkey)void

key:symbol?
Pops a value off the sequence atomically.

procedure

( mongo-dict-shift! mdkey)void

key:symbol?
Shifts a value off the sequence atomically.

procedure

( mongo-dict-pull! mdkeyval)void

key:symbol?
val:any/c
Remove a value to the sequence if it is present atomically.

procedure

( mongo-dict-pull*! mdkeyvals)void

key:symbol?
vals:sequence?
Removes a sequence of values to the sequence if they are present atomically.

4.2StructuresπŸ”— i

define-mongo-struct is a macro to create some convenience functions for Mongo dictionaries.

syntax

( define-mongo-struct structcollection
([fieldopt...]
...))
opt = #:required
| #:immutable
| #:ref
| #:set!
| #:inc
| #:null
| #:push
| #:append
| #:set-add
| #:set-add*
| #:pop
| #:shift
| #:pull
| #:pull*
struct : identifier?
collection : string?
field : identifier?
Defines make-struct and a set of operations for the fields.

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*! .

top
up

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /