Back

Relationship docs, strange stuff or not documented behaviour?

  • 0
  • Web
Camo
12 Feb, 2024, 19:12

in https://appwrite.io/docs/products/databases/relationships#create-documents we create a spiderman movie, with unique ID. ```js const { Client, Databases, ID } = require('node-appwrite');

const client = new Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('<PROJECT_ID>'); // Your project ID

const databases = new Databases(client);

await databases.createDocument( 'marvel', 'movies', ID.unique(), { title: 'Spiderman', year: 2002, reviews: [ { author: 'Bob', text: 'Great movie!' }, { author: 'Alice', text: 'Loved it!' } ] } ) but in the next update section, we update by passing title? not ID? js const { Client, Databases } = require('node-appwrite');

const client = new Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('<PROJECT_ID>'); // Your project ID

const databases = new Databases(client);

await databases.updateDocument( 'marvel', 'movies', 'spiderman', { title: 'Spiderman', year: 2002, reviews: [ 'review4', 'review5' ] } ); ``` how does this work?

TL;DR
Developers are discussing the use of the select query in the Appwrite SDK, similar to GraphQL. They are also wondering if there is a way to limit the fields returned to the client and if the nested creation can be achieved without relationships. One developer expresses concern about the amount of data returned by relationships, particularly in the context of a dashboard with multiple actions and notifications. They suggest having depth control for relationships. Another developer mentions that relationships are still in beta and lacking some crucial features. They ask if there is a way to limit the depth of relationships. Lastly, there is confusion about updating documents using the title instead of the ID.
Kenny
12 Feb, 2024, 19:18

That wouldn't work, I think it could be displayed like this to show in an easier to digest way that if you want to update the spiderman record use the ID for that record.

Camo
12 Feb, 2024, 19:32

might suggest then writing spiderman_ID so no questions would raise

Camo
12 Feb, 2024, 19:33

idk maybe its just me

Camo
12 Feb, 2024, 19:33

@Kenny i got another question you might answer based on relationships, can we limit the depth that is showing?

Kenny
12 Feb, 2024, 19:34

I don't think currently you can explicitly limit depth, but a depth of only 3 is shown.

Kenny
12 Feb, 2024, 19:34

Relationships are still in beta and as such are lacking some crutial features, imo.

Camo
12 Feb, 2024, 19:35

i would see depth control as a must

Camo
12 Feb, 2024, 19:36

i got dashboard -> action -> job and action-> notification

Camo
12 Feb, 2024, 19:36

so if any changes i get a refresh of all the data

Camo
12 Feb, 2024, 19:36

i still want to keep the relationships, for administrative purposes

Camo
12 Feb, 2024, 19:36

but the amount of incoming data might be overwhelming

Camo
12 Feb, 2024, 19:37

dashboard could have like 30 actions, which could have about 150 notifications, that's a lot of data

Kenny
12 Feb, 2024, 19:38

Yep, I agree. I've run into some limitations with relationships returning far too much data and making requests for documents take 30 seconds.

Camo
12 Feb, 2024, 19:42

i love the nested creation though, could be awesome if this could be achieved with out relationships, maybe it is ?

Camo
12 Feb, 2024, 19:43

i guess its not, how else would you know in which collection its supposed to go

Camo
12 Feb, 2024, 19:44

oh and one last question, is there a way to limit what fields get back to the client ? like private field or something?

Camo
12 Feb, 2024, 19:45

like graphql does, but with the sdk ?

Kenny
12 Feb, 2024, 19:54

On the root document you can use the select query to only return specific columns. Query.select(["column_name"])

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more
Copyright © 2024 Appwrite