On this page:

1 Accessing data

(mongo-connection? connection)  boolean?
  connection : any/c
Renamed mongo? from MongoDB.

Returns true if connection is object with some inforamtion about connection to mongo server.

(current-mongo-connection)  (or/c mongo-connection? false?)
(current-mongo-connection connection)  void?
  connection : (or/c mongo-connection? false?)
Stores mongo connection created by connect-to-mongo (mongo-connect). Used by mongo-use, mongo-use-database, mongo-dbs, etc. If connection is false - connection to server is not established.

If you want to use functions of this module with several mongo servers simultaneously - try parameterization (Dynamic Binding: parameterize).

(current-mongo-collection)  (or/c mongo-collection? false?)
(current-mongo-collection collection)  void?
  collection : (or/c mongo-collection? false?)
Simplifies database operations while you using one mongo collection: functions like mongo-save, mongo-find, mongo-update use it as the default parameter. Used by functions mongo-use-collection, mongo-use, connect-to-mongo. If collection is false - default collection is not selected.

(mongo-use-database database)  (or/c mongo-db? false?)
  database : (or/c mongo-db? string? false?)
Stores mongo-db or false in current-mongo-db. Accepts mongo-db or name of the database as string.

Automaticly switches current-mongo-collection to false.

Result is mongo-db or false.

(mongo-use-db database)  (or/c mongo-db? false?)
  database : (or/c mongo-db? string? false?)
Alias to mongo-use-database.

(mongo-use-collection collection)
  (or/c mongo-collection? false?)
  collection : (or/c mongo-collection? string? false?)
Stores mongo-collection, collection with given name or false in current-mongo-collection. Result is new value of current-mongo-collection.

Attention: look at Names issues about issues with names in the native console.

(mongo-use [#:collection collection 
  #:database database]) 
  (or/c false? mongo-collection? mongo-db?)
  collection : (or/c mongo-collection? string? false? void?)
   = (void)
  database : (or/c mongo-db? string? false? void?) = (void)
Combination of mongo-use-database and mongo-use-collection functions. If collection is specified, result will be value of current-mongo-collection], if database - value of current-mongo-database.

(connect-to-mongo [#:dbname dbname 
  #:host host 
  #:port port 
  #:collection collection]) 
  (or/c mongo-connection? mongo-collection? mongo-db?)
  dbname : (or/c string? false?) = #f
  host : string? = "localhost"
  port : number? = 27017
  collection : (or/c string? false?) = #f
Creates mongo connection and stores it in current-mongo-connection. Optionally accepts names of mongo database and mongo collection in that database. Returns current-mongo-connection if database name and colection was not specified, current-mongo-db if database name was specified, current-mongo-collection if both was specified.

(mongo-connect [#:dbname dbname 
  #:host host 
  #:port port 
  #:collection collection]) 
  (or/c mongo-connection? mongo-collection? mongo-db?)
  dbname : (or/c string? false?) = #f
  host : string? = "localhost"
  port : number? = 27017
  collection : (or/c string? false?) = #f
Alias to connect-to-mongo.