View Source Pointers.Virtual (bonfire v0.3.5-classic-beta.7)
Sets up an Ecto Schema for a Virtual Pointable
Virtual Pointables (or just
virtuals) are like pointables with no
additional columns, except instead of being backed by a table they
are backed by a view. This is more efficient of resources but only
works when there are no additional columns to add.
If you need to add columns to the schema, you should use a pointable.
use Pointers.Virtual, otp_app: :my_app, # your OTP application's name source: "my_table", # default name of view in database table_id: "01EBTVSZJ6X02J01R1XWWPWGZW" # valid ULID to identify virtual virtual_schema do # ... `has_one`, `has_many`, or *virtual* fields ONLY go here. end
Overriding with configuration
use (i.e. compilation time), we will attempt to load
configuration from the provided
:otp_app under the key of the
current module. Any values provided here will override the defaults
use. This allows you to configure them after the fact.
Additionally, pointables use
flex_schema(), so you can
provide additional configuration for those in the same place. Unlike
a regular pointable, you should not add additional
(non-virtual) fields, but it is permitted to add
I shall say it again because it's important: This happens at compile time. You must rebuild the app containing the pointable whenever the configuration changes.
Defines a function
__pointers__/1 to introspect data. Recognised
:table_id - retrieves the ULID id of the virtual.
:otp_app - retrieves the OTP application to which this belongs.