Skip to content

Commit

Permalink
Add index directives for keywords, symbols, sql equivalents, etc. in …
Browse files Browse the repository at this point in the history
…docs
  • Loading branch information
jaclarke committed Jan 30, 2025
1 parent e9368e7 commit 5c27147
Show file tree
Hide file tree
Showing 44 changed files with 391 additions and 23 deletions.
10 changes: 10 additions & 0 deletions docs/datamodel/access_policies.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
Access Policies
===============

.. index:: access policy, object-level security, row-level security, RLS,
allow, deny, using

Object types can contain security policies that restrict the set of objects
that can be selected, inserted, updated, or deleted by a particular query.
This is known as *object-level security* and it is similar in function to SQL's
Expand Down Expand Up @@ -378,6 +381,9 @@ is visible to a particular query.
Policy types
^^^^^^^^^^^^

.. index:: accesss policy, select, insert, delete, update, update read,
update write, all

For the most part, the policy types correspond to EdgeQL's *statement types*:

- ``select``: Applies to all queries; objects without a ``select`` permission
Expand Down Expand Up @@ -523,6 +529,8 @@ Custom error messages

.. versionadded:: 3.0

.. index:: access policy, errmessage, using

When you run a query that attempts a write and is restricted by an access
policy, you will get a generic error message.

Expand Down Expand Up @@ -583,6 +591,8 @@ will receive this error:
Disabling policies
^^^^^^^^^^^^^^^^^^

.. index:: apply_access_policies

You may disable all access policies by setting the ``apply_access_policies``
:ref:`configuration parameter <ref_std_cfg>` to ``false``.

Expand Down
2 changes: 2 additions & 0 deletions docs/datamodel/aliases.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
Aliases
=======

.. index:: alias, virtual type

.. important::

This section assumes a basic understanding of EdgeQL. If you aren't familiar
Expand Down
4 changes: 4 additions & 0 deletions docs/datamodel/annotations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
Annotations
===========

.. index:: annotation, title, description, deprecated

*Annotations* are named values associated with schema items and
are designed to hold arbitrary schema-level metadata represented as a
:eql:type:`str`.
Expand Down Expand Up @@ -52,6 +54,8 @@ should be used instead.
User-defined annotations
------------------------

.. index:: abstract annotation

To declare a custom annotation type beyond the three built-ins, add an abstract
annotation type to your schema. A custom annotation could be used to attach
arbitrary JSON-encoded data to your schema—potentially useful for introspection
Expand Down
2 changes: 2 additions & 0 deletions docs/datamodel/computeds.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Computeds

:edb-alt-title: Computed properties and links

.. index:: computeds, :=, __source__, backlinks

.. important::

This section assumes a basic understanding of EdgeQL. If you aren't familiar
Expand Down
12 changes: 12 additions & 0 deletions docs/datamodel/constraints.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
Constraints
===========

.. index:: constraint, validation, exclusive, expression on, one_of, max_value,
max_ex_value, min_value, min_ex_value, max_len_value, min_len_value,
regexp, __subject__

.. important::

This section assumes a basic understanding of EdgeQL.
Expand Down Expand Up @@ -202,6 +206,8 @@ Constraints can be defined on computed properties.
Composite constraints
^^^^^^^^^^^^^^^^^^^^^

.. index:: tuple

To define a composite constraint, create an ``exclusive`` constraint on a
tuple of properties or links.

Expand Down Expand Up @@ -239,6 +245,8 @@ Partial constraints

.. versionadded:: 2.0

.. index:: constraint exclusive on, except

Constraints on object types can be made partial, so that they don't apply
when some condition holds.

Expand Down Expand Up @@ -333,6 +341,8 @@ Link ``@source`` and ``@target`` constraints

.. versionadded:: 4.0

.. index:: constraint exclusive on, @source, @target

.. note::

``@source`` and ``@target`` are available starting with version 4.3.
Expand Down Expand Up @@ -412,6 +422,8 @@ using arbitrary EdgeQL expressions. The example below uses the built-in
Constraints and type inheritence
--------------------------------

.. index:: delegated constraint

If you define a constraint on a type and then extend that type, the constraint
will *not* be applied individually to each extending type. Instead, it will
apply globally across all the types that inherited the constraint.
Expand Down
7 changes: 7 additions & 0 deletions docs/datamodel/extensions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,18 @@
Extensions
==========

.. index:: using extension

Extensions are the way EdgeDB adds more functionality. In principle,
extensions could add new types, scalars, functions, etc., but, more
importantly, they can add new ways of interacting with the database.

Built-in extensions
-------------------

.. index:: edgeql_http, graphql, auth, ai, pg_trgm, pg_unaccent, pgcrypto,
pgvector

There are a few built-in extensions available:

- ``edgeql_http``: enables :ref:`EdgeQL over HTTP <ref_edgeql_http>`,
Expand Down Expand Up @@ -43,6 +48,8 @@ To enable these extensions, add a ``using`` statement at the top level of your s
Standalone extensions
---------------------

.. index:: postgis

Additionally, standalone extension packages can be installed via the CLI.

List installed extensions:
Expand Down
2 changes: 2 additions & 0 deletions docs/datamodel/functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
Functions
=========

.. index:: function, using

.. note::

This page documents how to define custom functions, however EdgeDB provides a
Expand Down
2 changes: 2 additions & 0 deletions docs/datamodel/future.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
Future Behavior
===============

.. index:: future, nonrecursive_access_policies

Any time that we add new functionality to EdgeDB we strive to do it in the
least disruptive way possible. Deprecation warnings, documentation and guides
can help make these transitions smoother, but sometimes the changes are just
Expand Down
4 changes: 4 additions & 0 deletions docs/datamodel/globals.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
Globals
=======

.. index:: global, required global

Schemas can contain scalar-typed *global variables*.

.. code-block:: sdl
Expand Down Expand Up @@ -151,6 +153,8 @@ default value.
Computed globals
----------------

.. index:: global, :=

Global variables can also be computed. The value of computed globals are
dynamically computed when they are referenced in queries.

Expand Down
10 changes: 10 additions & 0 deletions docs/datamodel/indexes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
Indexes
=======

.. index:: index on, performance, postgres query planner

An index is a data structure used internally to speed up filtering, ordering,
and grouping operations. Indexes help accomplish this in two key ways:

Expand Down Expand Up @@ -100,6 +102,8 @@ references multiple properties of the enclosing object type.
Index on multiple properties
----------------------------

.. index:: tuple

A *composite index* is an index that references multiple properties. This can
speed up queries that filter, order, or group on both properties.

Expand Down Expand Up @@ -137,6 +141,8 @@ In EdgeDB, this index is created by indexing on a ``tuple`` of properties.
Index on a link property
------------------------

.. index:: __subject__, linkprops

Link properties can also be indexed.

.. code-block:: sdl
Expand Down Expand Up @@ -168,6 +174,8 @@ Link properties can also be indexed.
Specify a Postgres index type
-----------------------------

.. index:: pg::hash, pg::btree, pg::gin, pg::gist, pg::spgist, pg::brin

.. versionadded:: 3.0

EdgeDB exposes Postgres indexes that you can use in your schemas. These are
Expand Down Expand Up @@ -201,6 +209,8 @@ You can use them like this:
Annotate an index
-----------------

.. index:: annotation

Indexes can be augmented with annotations.

.. code-block:: sdl
Expand Down
7 changes: 7 additions & 0 deletions docs/datamodel/inheritance.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
Inheritance
===========

.. index:: abstract, extending, extends, subtype, supertype, parent type,
child type

Inheritance is a crucial aspect of schema modeling in EdgeDB. Schema items can
*extend* one or more parent types. When extending, the child (subclass)
inherits the definition of its parents (superclass).
Expand Down Expand Up @@ -94,6 +97,8 @@ Polymorphic queries <ref_eql_select_polymorphic>`.
Multiple Inheritance
^^^^^^^^^^^^^^^^^^^^

.. index:: Multiple Inheritance

Object types can :ref:`extend more
than one type <ref_eql_sdl_object_types_inheritance>` — that's called
*multiple inheritance*. This mechanism allows building complex object
Expand Down Expand Up @@ -136,6 +141,8 @@ types out of combinations of more basic types.
Overloading
^^^^^^^^^^^

.. index:: overloaded

An object type can overload an inherited property or link. All overloaded
declarations must be prefixed with the ``overloaded`` prefix to avoid
unintentional overloads.
Expand Down
2 changes: 2 additions & 0 deletions docs/datamodel/introspection/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
Introspection
=============

.. index:: describe, introspect, typeof, schema module

All of the schema information in EdgeDB is stored in the ``schema``
:ref:`module <ref_datamodel_modules>` and is accessible via
*introspection queries*.
Expand Down
22 changes: 21 additions & 1 deletion docs/datamodel/links.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Links
=====

:index: link one-to-one one-to-many many-to-one many-to-many
.. index:: link, relation, source, target, backlinks, foreign key

Links define a specific relationship between two :ref:`object
types <ref_datamodel_object_types>`.
Expand All @@ -31,6 +31,8 @@ declared) and a *target* (the type they point to).
Link cardinality
----------------

.. index:: single, multi

All links have a cardinality: either ``single`` or ``multi``. The default is
``single`` (a "to-one" link). Use the ``multi`` keyword to declare a "to-many"
link.
Expand Down Expand Up @@ -76,6 +78,8 @@ declare a "to-one" backlink.
Required links
--------------

.. index:: required, optional, not null

All links are either ``optional`` or ``required``; the default is ``optional``.
Use the ``required`` keyword to declare a required link. A required link must
point to *at least one* target instance, and if the cardinality of the required
Expand Down Expand Up @@ -125,6 +129,8 @@ Attempting to create a ``GroupChat`` with no members would fail.
Exclusive constraints
---------------------

.. index:: constraint exclusive

You can add an ``exclusive`` constraint to a link to guarantee that no other
instances can link to the same target(s).

Expand Down Expand Up @@ -163,6 +169,9 @@ objects.
Modeling relations
------------------

.. index:: cardinality, one-to-one, one-to-many, many-to-one, many-to-many,
link table, association table

By combinining *link cardinality* and *exclusivity constraints*, we can model
every kind of relationship: one-to-one, one-to-many, many-to-one, and
many-to-many.
Expand Down Expand Up @@ -534,6 +543,8 @@ the link's shape:
Default values
--------------

.. index:: default

Like properties, links can declare a default value in the form of an EdgeQL
expression, which will be executed upon insertion. In the example below, new
people are automatically assigned three random friends.
Expand Down Expand Up @@ -562,6 +573,8 @@ people are automatically assigned three random friends.
Link properties
---------------

.. index:: linkprops, metadata, link table

Like object types, links in EdgeDB can contain **properties**. Link properties
can be used to store metadata about links, such as *when* they were created or
the *nature/strength* of the relationship.
Expand Down Expand Up @@ -786,6 +799,9 @@ a shape on the link.
Deletion policies
-----------------

.. index:: on target delete, on source delete, restrict, delete source, allow,
deferred restrict, delete target, if orphan

Links can declare their own **deletion policy**. There are two kinds of events
that might trigger these policies: *target deletion* and *source deletion*.

Expand Down Expand Up @@ -985,6 +1001,8 @@ deletion policy.
Polymorphic links
-----------------

.. index:: abstract, subtypes

Links can have ``abstract`` targets, in which case the link is considered
**polymorphic**. Consider the following schema:

Expand Down Expand Up @@ -1045,6 +1063,8 @@ docs <ref_eql_select_polymorphic>`
Abstract links
--------------

.. index:: abstract

It's possible to define ``abstract`` links that aren't tied to a particular
*source* or *target*. If you're declaring several links with the same set
of properties, annotations, constraints, or indexes, abstract links can be used
Expand Down
7 changes: 7 additions & 0 deletions docs/datamodel/mutation_rewrites.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
Mutation rewrites
=================

.. index:: rewrite, insert, update, using, __subject__, __specified__, __old__,
modify, modification

.. edb:youtube-embed:: ImgMfb_jCJQ?end=41
Mutation rewrites allow you to intercept database mutations (i.e.,
Expand Down Expand Up @@ -113,6 +116,8 @@ while updates will set the ``modified`` property:
Available variables
===================

.. index:: rewrite, __subject__, __specified__, __old__

Inside the rewrite rule's expression, you have access to a few special values:

* ``__subject__`` refers to the object type with the new property and link
Expand Down Expand Up @@ -286,6 +291,8 @@ containing the new author value.
Mutation rewrite as cached computed
===================================

..index:: cached computeds, caching computeds

Mutation rewrites can be used to effectively create a cached computed value as
demonstrated with the ``byline`` property in this schema:

Expand Down
Loading

0 comments on commit 5c27147

Please sign in to comment.