mungo/crud

Types

pub type FindOption {
  Skip(Int)
  Limit(Int)
  BatchSize(Int)
  Sort(List(#(String, bson.Value)))
  Projection(List(#(String, bson.Value)))
}

Constructors

  • Skip(Int)
  • Limit(Int)
  • BatchSize(Int)
  • Sort(List(#(String, bson.Value)))
  • Projection(List(#(String, bson.Value)))
pub type InsertResult {
  InsertResult(inserted: Int, inserted_ids: List(bson.Value))
}

Constructors

  • InsertResult(inserted: Int, inserted_ids: List(bson.Value))
pub type UpdateOption {
  Upsert
  ArrayFilters(List(List(#(String, bson.Value))))
}

Constructors

  • Upsert
  • ArrayFilters(List(List(#(String, bson.Value))))
pub type UpdateResult {
  UpdateResult(matched: Int, modified: Int)
  UpsertResult(matched: Int, upserted_id: bson.Value)
}

Constructors

  • UpdateResult(matched: Int, modified: Int)
  • UpsertResult(matched: Int, upserted_id: bson.Value)

Functions

pub fn count(collection: Collection, filter: List(
    #(String, Value),
  )) -> Result(Int, MongoError)
pub fn count_all(collection: Collection) -> Result(
  Int,
  MongoError,
)
pub fn delete_many(collection: Collection, filter: List(
    #(String, Value),
  )) -> Result(Int, MongoError)
pub fn delete_one(collection: Collection, filter: List(
    #(String, Value),
  )) -> Result(Int, MongoError)
pub fn find_all(collection: Collection, options: List(FindOption)) -> Result(
  Cursor,
  MongoError,
)
pub fn find_by_id(collection: Collection, id: String) -> Result(
  Option(Value),
  MongoError,
)
pub fn find_many(collection: Collection, filter: List(
    #(String, Value),
  ), options: List(FindOption)) -> Result(Cursor, MongoError)
pub fn find_one(collection: Collection, filter: List(
    #(String, Value),
  ), projection: List(#(String, Value))) -> Result(
  Option(Value),
  MongoError,
)
pub fn insert_many(collection: Collection, docs: List(
    List(#(String, Value)),
  )) -> Result(InsertResult, MongoError)
pub fn insert_one(collection: Collection, doc: List(
    #(String, Value),
  )) -> Result(Value, MongoError)
pub fn update_many(collection: Collection, filter: List(
    #(String, Value),
  ), change: List(#(String, Value)), options: List(UpdateOption)) -> Result(
  UpdateResult,
  MongoError,
)

for more information, see here

pub fn update_one(collection: Collection, filter: List(
    #(String, Value),
  ), change: List(#(String, Value)), options: List(UpdateOption)) -> Result(
  UpdateResult,
  MongoError,
)

for more information, see here

Search Document