eav

0

Описание

Entity-Attribute-Value pattern implementation for Elixir Ecto with PostgreSQL support

Языки

  • Elixir100%
год назад
год назад
год назад
год назад
год назад
год назад
год назад
README.md

EctoEAV

Entity-Attribute-Value pattern implementation for Elixir/Ecto with PostgreSQL support

License

Features

  • Dynamic attributes with type validation
  • One attribute value for one type, stored one times
  • PostgreSQL-specific optimizations
  • Migration generators
  • Complex query support
  • JSONB and array types handling
  • Sugar functions for operate with entities and attributes
  • View and Materialized View integration

[!WARNING] An entity can have only one attribute with a specific name and type. An attempt to add the same attribute with a different type will cause an exception.

Installation

Add to

mix.exs
:

Setup

  1. Generate migrations:
  1. Define entity schema:

Supported Types

PG and in schema/migration typeEcto type
:integer
:integer
:text
:string
:varchar
:string
bigint
:integer
:float
:float
:boolean
:boolean
:jsonb
:map
:bigint
{:array, :map}
text[]
{:array, :string}
:"bigint[]"
{:array, integer}
:jsonb[]
{:array, :map}

more coming soon ...

Usage

Add attributes

Queryng

Pretty view

Advanced Querying

Use predefined operators for complex queries:

Supported Operators

OPERATORPG OPERATORDescription
:=
=
Equal
All
:!=
<>
Not equal
All
:>
>
Greater than
Numeric
,
Date
:<
<
Less than
Numeric
,
Date
:>=
>=
Greater than or equal
Numeric
,
Date
:<=
<=
Less than or equal
Numeric
,
Date
:"@>"
@>
Contains
JSONB
,
Arrays
:"<@"
<@
Contained by
JSONB
,
Arrays
:&&
&&
Overlap
Arrays
:like
LIKE
Case-sensitive pattern match
String
:ilike
ILIKE
Case-insensitive pattern
String
:in
IN
List containment
All

Delete Attributes