mirror of
https://github.com/directus/directus.git
synced 2026-04-25 03:00:53 -04:00
Move system relations out of db
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
import { QueryBuilder } from 'knex';
|
||||
import { Query, Filter } from '../types';
|
||||
import { Query, Filter, Relation } from '../types';
|
||||
import { schemaInspector } from '../database';
|
||||
import Knex from 'knex';
|
||||
import { clone, isPlainObject } from 'lodash';
|
||||
import { systemRelationRows } from '../database/system-data/relations';
|
||||
|
||||
export default async function applyQuery(
|
||||
knex: Knex,
|
||||
@@ -58,7 +59,10 @@ export async function applyFilter(
|
||||
rootFilter: Filter,
|
||||
collection: string
|
||||
) {
|
||||
const relations = await knex.select('*').from('directus_relations');
|
||||
const relations: Relation[] = [
|
||||
...(await knex.select('*').from('directus_relations')),
|
||||
...systemRelationRows,
|
||||
];
|
||||
|
||||
addWhereClauses(rootQuery, rootFilter, collection);
|
||||
addJoins(rootQuery, rootFilter, collection);
|
||||
|
||||
@@ -17,6 +17,7 @@ import Knex from 'knex';
|
||||
import SchemaInspector from 'knex-schema-inspector';
|
||||
import { getRelationType } from '../utils/get-relation-type';
|
||||
import { systemFieldRows } from '../database/system-data/fields';
|
||||
import { systemRelationRows } from '../database/system-data/relations';
|
||||
|
||||
type GetASTOptions = {
|
||||
accountability?: Accountability | null;
|
||||
@@ -40,7 +41,10 @@ export default async function getASTFromQuery(
|
||||
* we might not need al this info at all times, but it's easier to fetch it all once, than trying to fetch it for every
|
||||
* requested field. @todo look into utilizing graphql/dataloader for this purpose
|
||||
*/
|
||||
const relations = await knex.select<Relation[]>('*').from('directus_relations');
|
||||
const relations = [
|
||||
...(await knex.select<Relation[]>('*').from('directus_relations')),
|
||||
...systemRelationRows,
|
||||
];
|
||||
|
||||
const permissions =
|
||||
accountability && accountability.admin !== true
|
||||
|
||||
Reference in New Issue
Block a user