mirror of
https://github.com/directus/directus.git
synced 2026-04-25 03:00:53 -04:00
* test to split up root query into sub queries * moved splitter to driver * moved splitter to data-sql * filtered o2m within conversion * removed splitter * fix * fix * util to get root query * refactoring, preparation for root and sub queries * preparations for making separate sub queries * refactoring * implemented creation of sub query * made store in relational metadata mandatory * fixed export * abstracted the database request * get root query definition * preparation to merge streams * started converting nested many queries in converter Co-authored-by: Nicola Krumschmidt <nickrum@users.noreply.github.com> * refactoring * at least two childnodes for logical operator * refactoring missing module * fixed tests for fields * refactoring, mainly rename current to internal * start integrating second approach * getting closer but wip * getting closer * fixed naming * merged streams into final stream Co-authored-by: Brainslug <br41nslug@users.noreply.github.com> * fixed returning array Co-authored-by: Nicola Krumschmidt <nickrum@users.noreply.github.com> * added generic type * use existing many join node again * fixed test * made use of generic type * changed wording for relational stuff * composite keys * new generator for sub query parameters Co-authored-by: Nicola Krumschmidt <nickrum@users.noreply.github.com> * worked on index test * more specific return type for driver * fixed index file tests * removed approach on abstract query level * worked on index test but wip * simple test for nested many node * continued on index test * finally finished test * randomized test values again * moved common nested many logic up to data-sql * remove closing controller * typedocs and error handling * single test for nested many querying logic * refactor: added utility function for streams * Remove unneeded type declaration * Remove bind call * Use AtLeastOneElement type alias * Use unknown instead of any as value of Records * Rename loadAllResultIntoMemory to readToEnd * Fix o2m with compound keys * Fix type error in createJoin * Simplify AbstractSqlNestedMany type * catch error of conversion in data-sql * removed additional error handling in driver * replaced table alias with actual table name * Allow join field values to be numbers again * Clarify property names on AbstractSqlNestedMany some more * nested many node creation tests * docs --------- Co-authored-by: Pascal Jufer <pascal-jufer@bluewin.ch> Co-authored-by: Nicola Krumschmidt <nickrum@users.noreply.github.com> Co-authored-by: Brainslug <br41nslug@users.noreply.github.com> Co-authored-by: Nicola Krumschmidt <nicola.krumschmidt@freenet.de>
@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.