(attribute-map attributes)
Returns a map of qualified key -> attribute for the given attributes
Returns a map of qualified key -> attribute for the given attributes
(attributes->eql attrs)
Returns an EQL query for all of the attributes that are available for the given database-id
Returns an EQL query for all of the attributes that are available for the given database-id
(defattr sym & args)
Define a new attribute into a sym.
WARNING: IF YOU ARE DOING FULL-STACK, THEN THESE MUST BE DEFINED IN CLJC FILES FOR RAD TO WORK! RAD actually supports the idea of having rendering plugins that work just in the JVM, in which case all of your code can be CLJ. It can also support client-side database adapters, which would mean that all of your code would be CLJS.
sym
: The name of the new var to create.qualified-keyword
: The unique (keyword) name of this attribute.data-type
: A supported data type (e.g. :int, :uuid, :ref, :instant).options-map
: An open map (any data can be placed in here) of key-value pairs.An attribute defines a logical bit of data in your graph model that may be stored in a database, derived by complex logic, or simply generated out of thin air. Attributes are the central place in RAD where information about your desired data model is supplied.
The most common options to put in options-map
are:
::attr/identities
- if persisted in storage, but NOT a table/row/entity key.::attr/identity?
- if a PK or natural key::attr/schema
- if persisted in storage::attr/target
- if type :ref
See the attributes-options
namespace for more details.
Attributes types are extensible (though there are many built in), and the concept of traversal to to-one and to-many edges in either direction is very easily represented in a natural, database-independent, fashion (though database adapters may require you to supply more information in order for them to actually do concrete work for you).
A attribute is required to have a qualified key that uniquely designates its name in the model, and a data
type. The options map is a completely open map of key-value pairs that can further describe the details of
an attribute. Some of those are standard options (found in the attributes-options namespace), and many more
are defined by reports, forms, database adapters, and rendering plugins. Look for *-options
namespaces in
order to find vars with docstrings that describe the possible options.
Define a new attribute into a sym. WARNING: IF YOU ARE DOING FULL-STACK, THEN THESE MUST BE DEFINED IN CLJC FILES FOR RAD TO WORK! RAD actually supports the idea of having rendering plugins that work just in the JVM, in which case all of your code can be CLJ. It can also support client-side database adapters, which would mean that all of your code would be CLJS. * `sym`: The name of the new var to create. * `qualified-keyword`: The unique (keyword) name of this attribute. * `data-type`: A supported data type (e.g. :int, :uuid, :ref, :instant). * `options-map`: An open map (any data can be placed in here) of key-value pairs. An attribute defines a logical bit of data in your graph model that may be stored in a database, derived by complex logic, or simply generated out of thin air. Attributes are the central place in RAD where information *about* your desired data model is supplied. The most common options to put in `options-map` are: * `::attr/identities` - if persisted in storage, but NOT a table/row/entity key. * `::attr/identity?` - if a PK or natural key * `::attr/schema` - if persisted in storage * `::attr/target` - if type `:ref` See the `attributes-options` namespace for more details. Attributes types are extensible (though there are many built in), and the concept of traversal to to-one and to-many edges in either direction is very easily represented in a natural, database-independent, fashion (though database adapters may require you to supply more information in order for them to actually do concrete work for you). A attribute is required to have a *qualified key* that uniquely designates its name in the model, and a data type. The options map is a completely open map of key-value pairs that can further describe the details of an attribute. Some of those are standard options (found in the attributes-options namespace), and many more are defined by reports, forms, database adapters, and rendering plugins. Look for `*-options` namespaces in order to find vars with docstrings that describe the possible options.
(encrypt password salt iterations)
Returns a cryptographycally-secure hashed password based on the given a plain-text password,
a random salt string (see gen-salt
), and a number of iterations. You should save the hashed result, salt, and
iterations in your database. Checking a password is then taking the password the user supplied, passing it through
this function with the original salt and iterations, and seeing if the hashed result is the same as the original.
Returns a cryptographycally-secure hashed password based on the given a plain-text password, a random salt string (see `gen-salt`), and a number of iterations. You should save the hashed result, salt, and iterations in your database. Checking a password is then taking the password the user supplied, passing it through this function with the original salt and iterations, and seeing if the hashed result is the same as the original.
(eql-query attr-query)
Convert a query that uses attributes (records) as keys into the proper EQL query. I.e. (eql-query [account/id]) => [::account/id] Honors metadata and join nesting.
Convert a query that uses attributes (records) as keys into the proper EQL query. I.e. (eql-query [account/id]) => [::account/id] Honors metadata and join nesting.
(make-attribute-validator attributes)
Creates a function that can be used as a form validator for any form that contains the given attributes
. If the
form asks for validation on an attribute that isn't listed or has no ::attr/valid?
function then it will consider
that attribute valid.
Creates a function that can be used as a form validator for any form that contains the given `attributes`. If the form asks for validation on an attribute that isn't listed or has no `::attr/valid?` function then it will consider that attribute valid.
(new-attribute kw type m)
Create a new attribute, which is represented as an Attribute record.
NOTE: attributes are usable as functions which act like their qualified keyword. This allows code-navigable
use of attributes throughout the system...e.g (account/id props) is like (::account/id props), but will
be understood by an IDE's jump-to feature when you want to analyze what account/id is. Use defattr
to
populate this into a symbol.
Type can be one of :string, :int, :uuid, etc. (more types are added over time, so see main documentation and your database adapter for more information).
The remaining argument is an open map of additional things that any subsystem can use to describe facets of this attribute that are important to your system.
If :ref
is used as the type then the ultimate ID of the target entity should be listed in m
under the ::target key.
Create a new attribute, which is represented as an Attribute record. NOTE: attributes are usable as functions which act like their qualified keyword. This allows code-navigable use of attributes throughout the system...e.g (account/id props) is like (::account/id props), but will be understood by an IDE's jump-to feature when you want to analyze what account/id is. Use `defattr` to populate this into a symbol. Type can be one of :string, :int, :uuid, etc. (more types are added over time, so see main documentation and your database adapter for more information). The remaining argument is an open map of additional things that any subsystem can use to describe facets of this attribute that are important to your system. If `:ref` is used as the type then the ultimate ID of the target entity should be listed in `m` under the ::target key.
(to-many? attr)
Returns true if the attribute with the given key is a to-many.
Returns true if the attribute with the given key is a to-many.
(to-one? attr)
Returns true if the attribute with the given key is a to-one.
Returns true if the attribute with the given key is a to-one.
(valid-value? {:com.fulcrologic.rad.attributes/keys [required? valid?]
:as attribute}
value)
Checks if the value looks to be a valid value based on the ::attr/required? and ::attr/valid? options of the given attribute.
Checks if the value looks to be a valid value based on the ::attr/required? and ::attr/valid? options of the given attribute.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close