mongo/crud

Types

pub type UpdateResult {
  UpdateResult(n: Int, modified: Int)
  UpsertResult(n: Int, upserted: object_id.ObjectId)
}

Constructors

  • UpdateResult(n: Int, modified: Int)
  • UpsertResult(n: Int, upserted: object_id.ObjectId)

Functions

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