This feature allows you to specify `collection` for the join field as
array.
This can be useful for example to describe relationship linking like
this:
```ts
{
slug: 'folders',
fields: [
{
type: 'join',
on: 'folder',
collection: ['files', 'documents', 'folders'],
name: 'children',
},
{
type: 'relationship',
relationTo: 'folders',
name: 'folder',
},
],
},
{
slug: 'files',
upload: true,
fields: [
{
type: 'relationship',
relationTo: 'folders',
name: 'folder',
},
],
},
{
slug: 'documents',
fields: [
{
type: 'relationship',
relationTo: 'folders',
name: 'folder',
},
],
},
```
Documents and files can be placed to folders and folders themselves can
be nested to other folders (root folders just have `folder` as `null`).
Output type of `Folder`:
```ts
export interface Folder {
id: string;
children?: {
docs?:
| (
| {
relationTo?: 'files';
value: string | File;
}
| {
relationTo?: 'documents';
value: string | Document;
}
| {
relationTo?: 'folders';
value: string | Folder;
}
)[]
| null;
hasNextPage?: boolean | null;
} | null;
folder?: (string | null) | Folder;
updatedAt: string;
createdAt: string;
}
```
While you could instead have many join fields (for example
`childrenFolders`, `childrenFiles`) etc - this doesn't allow you to
sort/filter and paginate things across many collections, which isn't
trivial. With SQL we use `UNION ALL` query to achieve that.
---------
Co-authored-by: Dan Ribbens <dan.ribbens@gmail.com>
29 lines
1.2 KiB
JSON
29 lines
1.2 KiB
JSON
{
|
|
"npm.packageManager": "pnpm",
|
|
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
|
"editor.formatOnSave": true,
|
|
"editor.codeActionsOnSave": {
|
|
"source.fixAll.eslint": "explicit"
|
|
},
|
|
"editor.formatOnSaveMode": "file",
|
|
"eslint.rules.customizations": [
|
|
// Defaultt all ESLint errors to 'warn' to differentate from TypeScript's 'error' level
|
|
{ "rule": "*", "severity": "warn" },
|
|
|
|
// Silence some warnings that will get auto-fixed
|
|
{ "rule": "perfectionist/*", "severity": "off", "fixable": true },
|
|
{ "rule": "curly", "severity": "off", "fixable": true },
|
|
{ "rule": "object-shorthand", "severity": "off", "fixable": true }
|
|
],
|
|
"typescript.tsdk": "node_modules/typescript/lib",
|
|
// Load .git-blame-ignore-revs file
|
|
"gitlens.advanced.blame.customArguments": ["--ignore-revs-file", ".git-blame-ignore-revs"],
|
|
"jestrunner.jestCommand": "pnpm exec cross-env NODE_OPTIONS=\"--no-deprecation\" node 'node_modules/jest/bin/jest.js'",
|
|
"jestrunner.changeDirectoryToWorkspaceRoot": false,
|
|
"jestrunner.debugOptions": {
|
|
"runtimeArgs": ["--no-deprecation"]
|
|
},
|
|
// Essentially disables bun test buttons
|
|
"bun.test.filePattern": "bun.test.ts"
|
|
}
|