module DynFork::QPaladins::Tools

Overview

Tools - A set of additional auxiliary methods for Paladins.

Direct including types

Defined in:

dynfork/paladins/tools.cr

Instance Method Summary

Instance Method Detail

def delete : Nil #

Delete a document from a collection in a database.


[View source]
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?

[View source]
def refrash_fields(doc_ptr : Pointer(BSON | Nil)) : Nil #

Refrash field values ​​after creating or updating a document.


[View source]
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

[View source]