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
- Docker Compose MongoDB Setup
everythings work fine but the mongodb fails on startup everytime. log: ``` Generating random MongoDB keyfile... /bin/bash: line 9: : No such file or directory ...
- Auth broken after update from 1.8.0 to 1...
So ive been having issues creating, deleting or updating users on my appwrite instance after i updated from 1.8.0 to version 1.9.0. When trying to create a user...
- Magic Link woes/noob
Magic Link is working; it sends the link to my email. But the link itself always leads to "Page Not Found. The page you're looking for doesn't exist". Clicking ...