module DynFork::QPaladins::Tools
Overview
Tools - A set of additional auxiliary methods for Paladins.
Direct including types
Defined in:
dynfork/paladins/tools.crInstance Method Summary
-
#delete : Nil
Delete a document from a collection in a database.
-
#print_err : Nil
Printing errors to the console.
-
#refrash_fields(doc_ptr : Pointer(BSON | Nil)) : Nil
Refrash field values after creating or updating a document.
-
#valid? : Bool
Check data validity.
Instance Method Detail
def print_err : Nil
#
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?
def refrash_fields(doc_ptr : Pointer(BSON | Nil)) : Nil
#
Refrash field values after creating or updating a document.
def valid? : Bool
#
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