Types
BulkResult = object nInserted*, nModified*, nRemoved*: int writeErrors*: seq[string]
- A result object for bulk write operations. Source Edit
Collection[TheSocket] {..} = ref object name*: string ## Collection name ## Database name, easier than ``coll.db.name`` db*: Database[TheSocket]
- Collection holds the Database data as db field. Source Edit
CommandKind = enum ckWrite, ckRead
- CommandKind is used to recognize whether the command is write or read. This is used significantly in case of server selection for multihost connections. Source Edit
Cursor[TheSocket] {..} = object id*: int64 firstBatch*: seq[BsonDocument] nextBatch*: seq[BsonDocument] db*: Database[TheSocket] ns*: string
- An object that will short-lived in a handle to fetch more data with the same identifier. Usually used for find queries variant. Source Edit
Database[TheSocket] {..} = ref object of RootObj name*: string db*: Mongo[TheSocket]
- Database holds the Mongo data as db field. Source Edit
GridFS[TheSocket] {..} = ref object name*: string files*: Collection[TheSocket] chunks*: Collection[TheSocket] chunkSize*: int32
-
GridFS is basically just a object that represents two different collections: i.e.
- {bucket.name}.files
- {bucket.name}.chunks
Which bucket.files stores the file information itself while bucket.chunks stores the actual binary information for the related files.
Source Edit Mongo[TheSocket] {..} = ref object of RootObj hosts*: seq[string] primary*: string servers*: TableRef[string, MongoConn[TheSocket]] db*: string writeConcern*: BsonDocument readPreference*: ReadPreference retryableWrites*: bool compressions*: seq[CompressorId]
- An ref object that will handle any necessary information as Mongo client. Since Mongo expected to live as long as the program alive, it can be expected to be a singleton throughout the program, however any lib user can spawn any instance of Mongo as like, but this should be avoided because of costly invocation of Mongo. Source Edit
MongoConn[TheSocket] {..} = ref object of RootObj isMaster*: bool pool*: Pool[TheSocket]
- Actual ref object that handles the connection to the intended server Source Edit
MongoError = object of CatchableError
- Source Edit
MongoUri = distinct string
- A special distinct uri string to support multihost uri connections. A single uri connection can rely using this too. Source Edit
Query[TheSocket] {..} = object query*: BsonDocument sort*: BsonBase projection*: BsonBase writeConcern*: BsonBase collection*: Collection[TheSocket] skip*, limit*, batchSize*: int32 readConcern*, max*, min*: BsonBase
- Query is basically any options that will be used when calling dbcommand find and others related commands. Must of these values are left to be default with only exception of query field. sort, projection, writeConcern all are BsonBase instead of BsonDocument because BsonBase is more flexible. Source Edit
ReadPreference {.pure.} = enum primary = "primary", primaryPreferred = "primaryPreferred", secondary = "secondary", secondaryPreferred = "secondaryPreferred", nearest = "nearest"
- Source Edit
SslInfo = object keyfile*: string ## Key file path certfile*: string ## Certificate file path when defined(ssl) or defined(nimdoc): protocol*: SslProtVersion ## The SSL/TLS protocol
- SslInfo will handle information for connecting with SSL/TLS connection. Source Edit
WriteResult = object success*: bool reason*: string case kind*: WriteKind of wkMany: n*: int errmsgs*: seq[string] ## For various error message when writing. of wkSingle: nil
- WriteResult is the result representing the write operations. The kind of wkSingle means represent the affected written/changed documents and wkMany the has that. Source Edit
Consts
verifypeer = false
- Source Edit
Procs
proc `[]`[T: MultiSock](dbase: Database[T]; name: string): Collection[T]
- Give new Collection from Database, expected to long-live object. Source Edit
proc authenticate[T: SHA1Digest | SHA256Digest](m: Mongo[AsyncSocket]): Future[ bool] {....stackTrace: false.}
- Authenticate Mongo with available username and password from Mongo object and delegate it to pool.authenticate. Source Edit
proc authenticate[T: SHA1Digest | SHA256Digest](m: Mongo[AsyncSocket]; user, pass: string): Future[bool] {....stackTrace: false.}
- Authenticate Mongo with given username and password and delegate it to pool.authenticate. Source Edit
proc authenticate[T: SHA1Digest | SHA256Digest](m: Mongo[Socket]): bool
- Authenticate Mongo with available username and password from Mongo object and delegate it to pool.authenticate. Source Edit
proc authenticate[T: SHA1Digest | SHA256Digest](m: Mongo[Socket]; user, pass: string): bool
- Authenticate Mongo with given username and password and delegate it to pool.authenticate. Source Edit
proc authenticated(m: Mongo): bool
- Source Edit
proc authenticated(m: MongoConn): bool
- Source Edit
proc collname(cur: Cursor): string
- Get Collection name from Cursor. Source Edit
proc flags(m: Mongo): QueryFlags
- Source Edit
proc hasUserAuth(m: Mongo): bool
- Source Edit
proc initQuery[T: MultiSock](query = bson(); collection: Collection[T] = nil; skip = 0'i32; limit = 0'i32; batchSize = 101'i32): Query[ T]
- Init query to be used for next find. Apparently this should be used for Query Plan Cache however currently the lib still hasn't support that feature yet. Source Edit
proc initSslInfo(keyfile, certfile: string; prot = protSSLv23): SslInfo {. ...raises: [], tags: [], forbids: [].}
- Init the SSLinfo which give default value of protocol to protSSLv23. It's preferable used when user want to use SSL/TLS connection. Source Edit
func isTailable(m: Mongo): bool
- Check whether Mongo is tailable set Source Edit
proc mainPreferred[T: MultiSock](m: Mongo[T]): MongoConn[T]
- Source Edit
proc newMongo[S: MultiSock](host = "localhost"; port = 27017; master = true; poolconn = poolconn; sslinfo = SslInfo(); ssl = defined(ssl)): Mongo[S]
- Give a new Mongo instance manually from given parameters. Source Edit
proc noTailable(m: Mongo)
- Set Mongo to not support TailableCursor Source Edit
proc secondaryPreferred[T: MultiSock](m: Mongo[T]): MongoConn[T]
- Source Edit
proc tailableCursor(m: Mongo)
- Set Mongo to support TailableCursor Source Edit
proc toCursor[S: MultiSock](b: BsonDocument): Cursor[S]
- Source Edit