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
- Invalid document structure: missing requ...
I just pick up my code that's working a week ago, and now I got this error: ``` code: 400, type: 'document_invalid_structure', response: { message: 'Inv...
- custom domain with CloudFlare
Hi all, it seems that CloudFlare has blocked cross-domain CNAME link which made my app hostname which is in CloudFlare, unable to create a CNAME pointing to clo...
- Custom emails
What happen if I use a third party email provider to customize my emails and my plan run out of emails/month? Appwrite emails are used as fallback sending emai...