
I have two questions with relationships.
- How can I define an ID in the relationed item being added.
.createDocument("645c032960cb9f95212b", "album", track.album.id, {
name: track.album.name,
href: track.album.external_urls.spotify,
popularity: track.album.popularity,
images: track.album.images?.map((image) => image.url) ?? [],
artist: [{
name: track.artists[i].name,
href: track.artists[i].external_urls.spotify,
popularity: track.artists[i].popularity,
images: track.artists[i].images?.map((image) => image.url) ?? [],
genres: track.artists[i].genres ?? [],
}],
track: [{
name: track.name,
href: track.external_urls.spotify,
popularity: track.popularity,
preview: track.preview_url,
explicit: track.explicit,
duration: track.duration_ms,
}],
})
With this code above how can I explicitly set the ID for Artist and Track.
- How can I relate a new item to an existing item?

hi Kenny, so what you are trying to do here is creating a child document on the fly which actually auto-matically link with Parent Document so you don't need to explicitily link here

Yea, but in another query at a later time I want to then relate a new item with an existing track.

yes you can archive that you just use update

And pass an array of artist/track document ids

As for specifying an id, set the $id attribute to whatever you want the id to be

example:
{
"level2": [
{
"$id": "level2",
"level3": [
{
"$id": "level3",
"level4": [
{
"$id": "level4",
"level5": [
{
"$id": "level5"
}
]
}
]
}
]
}
]
}

oh level 5 nesting is support, didn't knew 👀

Nope lol

only 3 levels

Can I close this if resolved @Vedsaga @Kenny

cc @Kenny actually he initially asked

Thanks everyone! This got me what I needed.

[SOLVED] Relationships IDs
Recommended threads
- 401 - Project is not accessible in this ...
This is on the app write console https://screen.aryanwadhera.tech/7YTVhLTf
- functions page returns 500
I am running selfhosted appwrite version 1.6.0 and all of a sudden my functions page stopped working, returning a 500. I don't see anything in the logs that wo...
- Custom domain not working properly
I am using custom domain for my appwrite cloud and I am trying to get JWT token but i am getting this error `API Route: Error verifying JWT or getting user: Typ...
