On this page:
mongo-save
mongo-save**
mongo-find-cursor
mongo-find
mongo-find One
mongo-update
mongo-get Collection Names
mongo-collections
mongo-dbs
mongo-object-id
mongo-find-by-id

2 Data manipulations

All functions in this section accepts collection as parameter. It can be mongo-collection or string that represents name of the collection. If you will not specify this parameter (current-mongo-collection) value will be used.

(mongo-save query [#:collection collection])  void?
  query : (or/c list? hash?)
  collection : (or/c mongo-collection? string?)
   = (current-mongo-collection)
Same as db.collection.save() in the native mongo shell. Look Queries for query syntax.

(mongo-save** query    
  [#:collection collection])  bson-objectid?
  query : (or/c list? hash?)
  collection : (or/c mongo-collection? string?)
   = (current-mongo-collection)
Experimental function. As for now it seems there is no function like "last inserted id". This function works the same as mongo-save but returns id of the last inserted record. To achieve this random key with random value inserted in the query -> query sent to database -> record that contains that random key value is fetched -> id of the record saved and instruction to modify record in database to remove random key is sent to database.

Maybe there exists easier way to do it so try not to use it straight.

(mongo-find-cursor [query    
  #:collection collection])  mongo-cursor?
  query : (or/c list? hash?) = '()
  collection : (or/c mongo-collection? string?)
   = (current-mongo-collection)
Same as db.collection.find() in the native mongo shell. Look Queries for query syntax.

Returns cursor.

(mongo-find [query #:collection collection])  list?
  query : (or/c list? hash?) = '()
  collection : (or/c mongo-collection? string?)
   = (current-mongo-collection)
Same as db.collection.find() in the native mongo shell. Look Queries for query syntax. Uses mongo-find-cursor.

Returns list of hashes as records that match query. If none is found empty list returned.

(mongo-findOne [query    
  #:collection collection])  (or/c hash? false?)
  query : (or/c list? hash?) = '()
  collection : (or/c mongo-collection? string?)
   = (current-mongo-collection)
Same as db.collection.findOne() in the native mongo shell. Look Queries for query syntax. Retreives cursor with mongo-find-cursor and fetches first record from it, then kills cursor.

Returns hash represention of record. If none is found result is false.

(mongo-update criteria    
  objNew    
  [upsert    
  multi    
  #:collection collection])  void?
  criteria : (or/c list? hash?)
  objNew : (or/c list? hash?)
  upsert : boolean? = #f
  multi : boolean? = #f
  collection : mongo-collection? = (current-mongo-collection)
Same as db.collection.update() in the native mongo shell. Look Queries for query syntax. Positive upsert means that object will be inserted in collection if nothing will match criteria. If multi is false update will be applied only at first found object, either if multi is true all objects matched criteria will be updated. Look original manual for additional explanations.

(mongo-getCollectionNames [#:database database])  list?
  database : (or/c mongo-db? string?) = (current-mongo-db)
Same as db.getCollectionNames() in the native mongo shell. Enumerates collection names in database.

(mongo-collections [#:database database])  list?
  database : (or/c mongo-db? string?) = (current-mongo-db)
Alias for mongo-getCollectionNames.

(mongo-dbs [#:connection connection])  list?
  connection : mongo-connection? = (current-mongo-connection)
Same as "show dbs" in the native mongo shell. Enumerates database names at the server.

(mongo-object-id object)  (or/c bson-objectid? false?)
  object : (or/c hash? list?)
Combination of (hash-ref object 'id) for hash representation of record and (cdr (assoc 'id object)) for list representation.

(mongo-find-by-id id)  (or/c hash? false?)
  id : bson-objectid?
Way to omit writing (mongo-findOne (list (cons 'id id))).