I have a surrealdb schema like this
Now what i need is select all the apis and folders and collection that belong to single workspace
the query that i have is this,
SELECT
->workspace_to_collection->collection.* AS collection,
(
SELECT
->collection_to_folder->folder.*
AS folders
FROM collection
) AS collection.folder
FROM workspaces:4yuie4oj7jrrhqvs3m7m;
and this give a result like this,
[
{
collection: [
{
description: 'Collection 2 description',
folder: [
{
folders: [
{
description: 'Folder 3 description',
id: folder:abu30525i5w0cbz5v2xf,
name: 'folder 3',
path: '/old',
timestamp: d'2024-12-09T04:28:08.053Z'
},
{
description: 'Folder 2 description',
id: folder:hj5k62gs0frezfctds6e,
name: 'folder 2',
path: '/new',
timestamp: d'2024-12-09T04:27:58.921Z'
},
{
description: 'Folder 1 description',
id: folder:ovmriv3z8xf11p4tiqbd,
name: 'folder 1',
path: '/create',
timestamp: d'2024-12-09T04:27:47.816Z'
}
]
},
{
folders: []
}
],
id: collection:icloni09dj0pl8knp6qi,
name: 'Collection 2',
path: '/dog',
timestamp: d'2024-12-09T04:24:23.091Z'
},
{
description: 'Collection 1 description',
folder: [
{
folders: [
{
description: 'Folder 3 description',
id: folder:abu30525i5w0cbz5v2xf,
name: 'folder 3',
path: '/old',
timestamp: d'2024-12-09T04:28:08.053Z'
},
{
description: 'Folder 2 description',
id: folder:hj5k62gs0frezfctds6e,
name: 'folder 2',
path: '/new',
timestamp: d'2024-12-09T04:27:58.921Z'
},
{
description: 'Folder 1 description',
id: folder:ovmriv3z8xf11p4tiqbd,
name: 'folder 1',
path: '/create',
timestamp: d'2024-12-09T04:27:47.816Z'
}
]
},
{
folders: []
}
],
id: collection:g3f7ep3th6jbv2b9kcbd,
name: 'Collection 1',
path: NULL,
timestamp: d'2024-12-08T14:25:33.920Z'
}
]
}
]
the result structure that i need is
collection: [
{
description: 'Collection 2 description',
folder: [
{
folders: [
{
description: 'Folder 3 description',
id: folder:abu30525i5w0cbz5v2xf,
name: 'folder 3',
path: '/old',
timestamp: d'2024-12-09T04:28:08.053Z'
api: []
},
{
description: 'Folder 2 description',
id: folder:hj5k62gs0frezfctds6e,
name: 'folder 2',
path: '/new',
timestamp: d'2024-12-09T04:27:58.921Z'
api: [
{method:"post",path"/"....}
]
},
{
description: 'Folder 1 description',
id: folder:ovmriv3z8xf11p4tiqbd,
name: 'folder 1',
path: '/create',
timestamp: d'2024-12-09T04:27:47.816Z'
api: [apis here]
}
]
}
],
id: collection:icloni09dj0pl8knp6qi,
name: 'Collection 2',
path: '/dog',
timestamp: d'2024-12-09T04:24:23.091Z'
},
{
id: collection:icloni09dj0pl8knp6qi,
name: 'Collection 2',
path: '/dog',
timestamp: d'2024-12-09T04:24:23.091Z'
folder: []
}
]
that is the structure that i need it like select every api and folder belong to this collection that is in this workspace with this id