Files
directus/packages/data
Jan Arends 6f0205d054 Durus: Filtering on m2o relations (#20222)
* initial ideas

Co-authored-by: Rijk van Zanten <rijkvanzanten@me.com>
Co-authored-by: Nicola Krumschmidt <nickrum@users.noreply.github.com>
Co-authored-by: ian <licitdev@users.noreply.github.com>

* removed function as target again

* converter test like the rest

* TDD test for converter

* TDD test for pg statement creation

* fix

* convert nested condition target

* test for function target conversion

* made condition nodes return join clause for nested filter

* handled the additional join for logical nodes

* adopted changes in filter test

* fixed test

* added join to modifiers

* Allow same target in all conditions

* Fix AbstractSqlQueryOrderNode type

* Fix deeply nested filter conversion

* Fix condition converters with nested target

* Make filter result clauses required

* Fix merging joins

* Fix convertLogical type

* Allow all SQL condition nodes to be functions

* fixed test

* rename

* new test, separated integration tests

* remove duplicated joins

* formatter

* fixed string condition

* adopted tests

* preparation for sort

* removed test complexity drastically

* clean up join duplicate removal

* unit test for modifier conversion

* reverted converter test

* removed join duplication removal

---------

Co-authored-by: Rijk van Zanten <rijkvanzanten@me.com>
Co-authored-by: Nicola Krumschmidt <nickrum@users.noreply.github.com>
Co-authored-by: ian <licitdev@users.noreply.github.com>
Co-authored-by: Nicola Krumschmidt <nicola.krumschmidt@freenet.de>
2023-11-10 18:40:47 +01:00
..
2023-05-10 14:30:53 -04:00
2023-10-20 18:55:45 +00:00
2023-09-26 21:14:27 +08:00

@directus/data

Warning

This is a work in progress. Nothing is expected to work yet.

Installation

npm install @directus/data

The installation of a driver is also required.

Usage

Setup

import { DataEngine } from '@directus/data';
import { DataDriverPostgres } from '@directus/data-driver-postgres';

// Instantiate the engine
const engine = new DataEngine();

// Instantiate a driver
const pgDriver = new DataDriverPostgres({
	connectionString: 'postgresql://root:password@localhost/mydb',
});

// register the driver to the engine
await engine.registerStore('postgres', pgDriver);

Query data

// query data
await engine.query({
	store: 'postgres',
	collection: 'articles',
	fields: [
		{
			type: 'primitive',
			field: 'id',
		},
	],
});

The above is resulting in the following flow.

graph TB;
    api --> data
	subgraph da[data abstraction]
		direction TB
		data --> data-driver-x --> db1[(datastore)]
		data --> data-driver-y --> db2[(datastore)]
	end

Current architecture of this package

To get an overview of how the package is organized regarding it's files, directories and the dependencies between them, run pnpm run depcruise and have a look in the created dependency-graph.svg image.