EEdgedb array usage

[tr] Türkçe Oku

2023-04-11

The array data type is used to store multiple data elements in a single data structure. In edgedb, the ‘array of’ syntax is used to define arrays. For example, the following example defines an array named colors which contains color names of type str:

CREATE TYPE Product {
  required property name -> str;
  required property colors -> array of str;
};

INSERT Product {
  name := "T-Shirt",
  colors := ["Red", "Green", "Blue"]
};

SELECT Product.colors;

In this example, an object type named Product is defined with an array property named colors. The INSERT statement creates an instance of the Product object type and assigns an array containing three different color names to the colors property. The SELECT statement queries the colors property of elements in the Product object type and returns the result

Arrays are a useful data structure in databases. edgedb provides a set of specialized processor functions for processing arrays. These functions can be used to sort elements within an array, search for specific elements or items within an array, filter elements within an array, aggregate elements within an array, and perform many other operations on arrays.

The following examples demonstrate array operations in Edgedb:

SELECT array_agg(User ORDER BY User.name);

SELECT User FILTER User.name IN ["John", "Alice"];

SELECT User FILTER User.name ILIKE "a%";

SELECT SUM(array_agg(Product.price));

These examples only show a few of the many functions that can be used to process arrays. edgedb provides many more functions for processing elements within an array.



More posts like this

Edgedb Computed Links

2023-04-12 | #edgedb #edgedb-links

Computed Links is a structure used to define relationships between two objects. These links are created by using a defined query or function to calculate the relationship between associated objects. Computed Links is a structure used to define relationships between two objects. These connections are created by using a defined query or function to calculate the relationship between the associated objects. This structure is very useful for ensuring consistency of the data held in the database.

Continue reading 


Edgedb Exclusive Constraint

2023-04-12 | #edgedb #edgedb-constraints

The term exclusive constraint in EdgeDB refers to a type of constraint that ensures a specific property is unique or within a certain range. For example, you can create an exclusive constraint in a User object that ensures the email property is unique, thus ensuring that each user is only saved once. In the following example, we are defining an exclusive constraint that ensures uniqueness in the email property: type User { required property id -> uuid; required property name -> str; exclusive constraint unique_email on (.

Continue reading 


Edgedb Constraints

2023-04-11 | #edgedb #edgedb-constraints

Edgedb is a relational database management system (RDBMS) that provides various constraint mechanisms to securely store and manage your data while preserving the integrity of the data recorded in your database. Constraints are a set of rules used to maintain the integrity of the data stored in your database. There are five different types of constraint: 1. Primary Key Constraints: Primary key constraints ensure that each row is uniquely identified. This constraint specifies that there can only be one primary key column in a table, and each value in this column can only be used once.

Continue reading 