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
- No server error on selfhosted appwrite
Please help me, my clients is ask what happen on their data? How can i make it up again?
- Upgrading selfhost version?
It is okay to upgrade version to higher one, of my current version is 1.7.4 to 1.8.1. Is that safe to do cause my clients already have data on that? Also is a...
- Streamlit UI and local DB
I want to use Appwrite for automation, like run watchdog service every morning 3 am. Anyone got suggestions, already explored github and documentation no luck. ...