Files
directus/packages/data
Jan Arends 08bbe27794 Durus: nested type refactoring (#20553)
* initial thoughts

* optional meta data for a2o with json

* added test

* some docs

* Adjust abstract query to support single column any relations

* fix build

* added relational any option to nested one

* applied type refactoring in converter

* improved a2o relation definition

* no pk column name in any json column

* added place for a2o sub query generator

* docs on type

* deleted test

Co-authored-by: Nicola Krumschmidt <nickrum@users.noreply.github.com>

* docs

* reverted preps

* renamed meta to nesting

* removed reverted prep

* removed unnecessary check

* docs

* renamed meta

Co-authored-by: Nicola Krumschmidt <nicola.krumschmidt@freenet.de>

---------

Co-authored-by: Nicola Krumschmidt <nicola.krumschmidt@freenet.de>
Co-authored-by: Nicola Krumschmidt <nickrum@users.noreply.github.com>
2023-12-04 18:18:55 +00:00
..
2023-05-10 14:30:53 -04: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.