module DynFork::QCommons::One

Overview

Requests like find one.

Extended Modules

Direct including types

Defined in:

dynfork/commons/one.cr

Instance Method Summary

Instance Method Detail

def delete_one(filter, *, collation : Mongo::Collation | Nil = nil, hint : String | Hash | NamedTuple | Nil = nil, ordered : Bool | Nil = nil, write_concern : Mongo::WriteConcern | Nil = nil, session : Mongo::Session::ClientSession | Nil = nil) : Mongo::Commands::Common::DeleteResult | Nil #

Deletes one document.

NOTE For more details, please check the official documentation.

NOTE For more details, please check the cryomongo documentation.


[View source]
def find_one_and_delete(filter, *, sort = nil, fields = nil, bypass_document_validation : Bool | Nil = nil, write_concern : Mongo::WriteConcern | Nil = nil, collation : Mongo::Collation | Nil = nil, hint : String | Hash | NamedTuple | Nil = nil, max_time_ms : Int64 | Nil = nil, session : Mongo::Session::ClientSession | Nil = nil) : self | Nil #

Finds a single document and deletes it, returning the original. The document to return may be nil.

NOTE For more details, please check the official documentation.

NOTE For more details, please check the cryomongo documentation.

Example:

model_name : ModelName? = ModelName.find_one_and_delete({_id: id})

[View source]
def find_one_to_hash(filter = BSON.new, *, sort = nil, projection = nil, hint : String | Hash | NamedTuple | Nil = nil, skip : Int32 | Nil = nil, comment : String | Nil = nil, max_time_ms : Int64 | Nil = nil, read_concern : Mongo::ReadConcern | Nil = nil, max = nil, min = nil, return_key : Bool | Nil = nil, show_record_id : Bool | Nil = nil, oplog_replay : Bool | Nil = nil, no_cursor_timeout : Bool | Nil = nil, allow_partial_results : Bool | Nil = nil, collation : Mongo::Collation | Nil = nil, read_preference : Mongo::ReadPreference | Nil = nil, session : Mongo::Session::ClientSession | Nil = nil) : Hash(String, DynFork::Globals::FieldValueTypes) | Nil #

Find the document and convert it to a Hash object.

NOTE For more details, please check the official documentation.

NOTE For more details, please check the cryomongo documentation.

Example:

doc_hash : Hash(String, DynFork::Globals::FieldValueTypes)? = ModelName.find_one_to_hash({_id: id})

[View source]
def find_one_to_instance(filter = BSON.new, *, sort = nil, projection = nil, hint : String | Hash | NamedTuple | Nil = nil, skip : Int32 | Nil = nil, comment : String | Nil = nil, max_time_ms : Int64 | Nil = nil, read_concern : Mongo::ReadConcern | Nil = nil, max = nil, min = nil, return_key : Bool | Nil = nil, show_record_id : Bool | Nil = nil, oplog_replay : Bool | Nil = nil, no_cursor_timeout : Bool | Nil = nil, allow_partial_results : Bool | Nil = nil, collation : Mongo::Collation | Nil = nil, read_preference : Mongo::ReadPreference | Nil = nil, session : Mongo::Session::ClientSession | Nil = nil) : self | Nil #

Finds the document and converts it to a Model instance.

NOTE For more details, please check the official documentation.

NOTE For more details, please check the cryomongo documentation.

Example:

model_name : ModelName? = ModelName.find_one_to_instance({_id: id})

[View source]
def find_one_to_json(filter = BSON.new, *, sort = nil, projection = nil, hint : String | Hash | NamedTuple | Nil = nil, skip : Int32 | Nil = nil, comment : String | Nil = nil, max_time_ms : Int64 | Nil = nil, read_concern : Mongo::ReadConcern | Nil = nil, max = nil, min = nil, return_key : Bool | Nil = nil, show_record_id : Bool | Nil = nil, oplog_replay : Bool | Nil = nil, no_cursor_timeout : Bool | Nil = nil, allow_partial_results : Bool | Nil = nil, collation : Mongo::Collation | Nil = nil, read_preference : Mongo::ReadPreference | Nil = nil, session : Mongo::Session::ClientSession | Nil = nil) : String | Nil #

Finds the document and converts it to a json string.

NOTE For more details, please check the official documentation.

NOTE For more details, please check the cryomongo documentation.

Example:

json_str : String? = ModelName.find_one_to_json({_id: id})

[View source]