DynFork::QPaladins::Tools
Tools - A set of additional auxiliary methods for Paladins.
Instance methods
delete(delete_files? : Bool = true, 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) : Nil
Delete a document from a collection in a database. 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:
user : User? = User.find_one({_id: id})
user.delete
print_err
Printing errors to the console. Convenient to use during development.
Example:
@[DynFork::Meta(service_name: "Accounts")]
struct User < DynFork::Model
getter username = DynFork::Fields::TextField.new
getter birthday = DynFork::Fields::DateField.new
end
user = User.new
user.print_err unless user.valid?
refrash_fields(doc_bson : BSON) : Nil
Refrash field values after creating or updating a document.
valid?
Check data validity. NOTE: the main use is to check data from web forms.
Example:
@[DynFork::Meta(service_name: "Accounts")]
struct User < DynFork::Model
getter username = DynFork::Fields::TextField.new
getter birthday = DynFork::Fields::DateField.new
end
user = User.new
if user.valid?
# your code...
end