mongo/crud

Types

pub type FindOption {
  Skip(Int)
  Limit(Int)
  BatchSize(Int)
  Sort(value.Value)
  Projection(value.Value)
}

Constructors

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

Constructors

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

Constructors

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

Constructors

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

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(
  Cursor,
  MongoError,
)
pub fn find_by_id(collection: Collection, id: String) -> Result(
  Option(Value),
  MongoError,
)
pub fn find_many(collection: Collection, filter: Value, options: List(
    FindOption,
  )) -> Result(Cursor, MongoError)
pub fn find_one(collection: Collection, filter: Value, projection: Value) -> Result(
  Option(Value),
  MongoError,
)
pub fn insert_many(collection: Collection, docs: List(Value)) -> Result(
  InsertResult,
  MongoError,
)
pub fn insert_one(collection: Collection, doc: Value) -> Result(
  Value,
  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)
Search Document