src/anonimongo/dbops/crud

Search:
Group by:
Source   Edit  

Query and Write Operation Commands

This APIs can be referred here. This module handling all main CRUD operations and all of these are returning BsonDocument to give a higher-level APIs to handle the document.

One caveat that's different from the Mongo is each of these API has additional parameter explain string which default to "" (empty string), or explainVerbosity in case explain already defined before. Any non empty explain value will regarded as Cached Query and will invoke the diagnostic.explain. Available explain values are "allPlansExecution", "queryPlanner", and "executionStats".

The usage of getLastError discouraged as it's backward compability with older Mongo version and unnecessary with Acknowledged Query as the error immediately returned when operation failed.

All APIs are async.

__ here

Procs

proc delete(db: Database[AsyncSocket]; coll: string; deletes: seq[BsonDocument];
            ordered = true; wt = bsonNull(); explain = ""): Future[BsonDocument] {.
    ...stackTrace: false, raises: [Exception, ValueError],
    tags: [RootEffect, TimeEffect, WriteIOEffect, ReadIOEffect], forbids: [].}
Source   Edit  
proc delete(db: Database[Socket]; coll: string; deletes: seq[BsonDocument];
            ordered = true; wt = bsonNull(); explain = ""): BsonDocument {....raises: [
    KeyError, ValueError, MongoError, IOError, OSError, Exception, SnappyError,
    ZippyError, SslError, TimeoutError],
    tags: [WriteIOEffect, ReadIOEffect, RootEffect, TimeEffect], forbids: [].}
Source   Edit  
proc find(db: Database[AsyncSocket]; coll: string; query = bson();
          sort = bsonNull(); selector = bsonNull(); hint = bsonNull(); skip = 0;
          limit = 0; batchSize = 101; singleBatch = false; comment = "";
          maxTimeMS = 0; readConcern = bsonNull(); max = bsonNull();
          min = bsonNull(); returnKey = false; showRecordId = false;
          tailable = false; awaitData = false; oplogReplay = false;
          noCursorTimeout = false; partial = false; collation = bsonNull();
          explain = ""): Future[BsonDocument] {....gcsafe, stackTrace: false,
    raises: [Exception, ValueError],
    tags: [RootEffect, TimeEffect, WriteIOEffect, ReadIOEffect], forbids: [].}
Source   Edit  
proc find(db: Database[Socket]; coll: string; query = bson(); sort = bsonNull();
          selector = bsonNull(); hint = bsonNull(); skip = 0; limit = 0;
          batchSize = 101; singleBatch = false; comment = ""; maxTimeMS = 0;
          readConcern = bsonNull(); max = bsonNull(); min = bsonNull();
          returnKey = false; showRecordId = false; tailable = false;
          awaitData = false; oplogReplay = false; noCursorTimeout = false;
          partial = false; collation = bsonNull(); explain = ""): BsonDocument {.
    ...gcsafe, raises: [ValueError, Exception, KeyError, MongoError, IOError,
                     OSError, SnappyError, ZippyError, SslError, TimeoutError],
    tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
Source   Edit  
proc findAndModify(db: Database[AsyncSocket]; coll: string; query = bson();
                   sort = bsonNull(); remove = false; update = bsonNull();
                   new = false; fields = bsonNull(); upsert = false;
                   bypass = false; wt = bsonNull(); collation = bsonNull();
                   arrayFilters: seq[BsonDocument] = @[]; explain = ""): Future[
    BsonDocument] {....stackTrace: false, raises: [Exception, ValueError], tags: [
    RootEffect, TimeEffect, WriteIOEffect, ReadIOEffect], forbids: [].}
Source   Edit  
proc findAndModify(db: Database[Socket]; coll: string; query = bson();
                   sort = bsonNull(); remove = false; update = bsonNull();
                   new = false; fields = bsonNull(); upsert = false;
                   bypass = false; wt = bsonNull(); collation = bsonNull();
                   arrayFilters: seq[BsonDocument] = @[]; explain = ""): BsonDocument {....raises: [
    ValueError, Exception, KeyError, MongoError, IOError, OSError, SnappyError,
    ZippyError, SslError, TimeoutError],
    tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
Source   Edit  
proc getLastError(db: Database[AsyncSocket]; opt = bson()): Future[BsonDocument] {.
    ...stackTrace: false, raises: [Exception, ValueError],
    tags: [RootEffect, TimeEffect, WriteIOEffect, ReadIOEffect], forbids: [].}
Source   Edit  
proc getLastError(db: Database[Socket]; opt = bson()): BsonDocument {....raises: [
    KeyError, ValueError, MongoError, IOError, OSError, Exception, SnappyError,
    ZippyError, SslError, TimeoutError],
    tags: [WriteIOEffect, ReadIOEffect, RootEffect, TimeEffect], forbids: [].}
Source   Edit  
proc getMore(db: Database[AsyncSocket]; cursorId: int64; collname: string;
             batchSize: int; maxTimeMS = -1): Future[BsonDocument] {.
    ...stackTrace: false, raises: [Exception, ValueError],
    tags: [RootEffect, TimeEffect, WriteIOEffect, ReadIOEffect], forbids: [].}
Source   Edit  
proc getMore(db: Database[Socket]; cursorId: int64; collname: string;
             batchSize: int; maxTimeMS = -1): BsonDocument {....raises: [KeyError,
    ValueError, MongoError, IOError, OSError, Exception, SnappyError,
    ZippyError, SslError, TimeoutError],
    tags: [WriteIOEffect, ReadIOEffect, RootEffect, TimeEffect], forbids: [].}
Source   Edit  
proc insert(db: Database[AsyncSocket]; coll: string;
            documents: seq[BsonDocument]; ordered = true; wt = bsonNull();
            bypass = false; explain = ""): Future[BsonDocument] {.
    ...stackTrace: false, raises: [Exception, ValueError],
    tags: [RootEffect, TimeEffect, WriteIOEffect, ReadIOEffect], forbids: [].}
Source   Edit  
proc insert(db: Database[Socket]; coll: string; documents: seq[BsonDocument];
            ordered = true; wt = bsonNull(); bypass = false; explain = ""): BsonDocument {....raises: [
    ValueError, Exception, KeyError, MongoError, IOError, OSError, SnappyError,
    ZippyError, SslError, TimeoutError],
    tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
Source   Edit  
proc update(db: Database[AsyncSocket]; coll: string; updates: seq[BsonDocument];
            ordered = true; wt = bsonNull(); bypass = false; explain = ""): Future[
    BsonDocument] {....stackTrace: false, raises: [Exception, ValueError], tags: [
    RootEffect, TimeEffect, WriteIOEffect, ReadIOEffect], forbids: [].}
Source   Edit  
proc update(db: Database[Socket]; coll: string; updates: seq[BsonDocument];
            ordered = true; wt = bsonNull(); bypass = false; explain = ""): BsonDocument {....raises: [
    ValueError, Exception, KeyError, MongoError, IOError, OSError, SnappyError,
    ZippyError, SslError, TimeoutError],
    tags: [RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect], forbids: [].}
Source   Edit