Understanding Pointers #109
-
I have a scenario analogous to the following setup: Consider a public struct User: ParseUser {
/**
All the standard variables.
*/
public var nickname: String?
public var metadata: Pointer<Metadata>?
} and a public struct Metadata: ParseObject {
/**
All the standard variables.
*/
public var user: Pointer<User>?
public var photo: ParseFile?
public var parentName: String?
} i.e. I want the ability to traverse from a User object to their Metadata object (e.g. to set and get the user’s photo and parent name), and the ability to fetch a Metadata object, and get to that user’s nickname. However, if I have a query, say: let query = Metadata.query ( "parentName" == "Dave" )
.include("user")
let result = try? await query.first() I notice that I won’t have access to the User object through |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
The compiler providing this type of error is a suggestion towards a design improvement in your schema (you are basically designing in a way that can create cycles). If you want to keep your current schema setup then the extra fetch you mentioned works as a solution and You can also look at join tables: |
Beta Was this translation helpful? Give feedback.
The compiler providing this type of error is a suggestion towards a design improvement in your schema (you are basically designing in a way that can create cycles). If you want to keep your current schema setup then the extra fetch you mentioned works as a solution and
include
won't help because if you create a cycle you could end up making your server go in an infinite recursion loop. You can also look at relations, but you will most likely still need the extra fetch. The pointer in Playgrounds demonstrates the solution you posted as well as others.You can also loo…