Search code examples
baqend

Data objects that reference each other


Will it cause a problem if I have objects referencing each other?

For example:

Jobs - ACL = not writeable by public
  id: 10
  jobname: 'Inside Sales Rep'
  applicants: /db/Applicants/123456  // a refernece, not a string

Applicants - ACL = writeable by public
  id: 123456
  applicants: ["/db/User/1", "/db/User/2"]
  job: /db/Jobs/10  // a reference, not a string

What's going on here is we have some jobs, and in a separate data class a Set that represents what users have applied for the job. As they apply, their user ID is pushed onto the Set. If they have to withdrawl, their user ID is removed from the set.

So what I'm hoping to accomplish is something like, find all jobs where user X has applied, and return those job names.

This works great, but is this going to cause some weird loop issue? I noticed when I do my query and console the result, I do get this pattern:

Jobs
  Applicants
     Jobs
        Applicants
          ..... it will just keep going as long as I request it to load

Any thoughts?


Solution

  • Loops in references are allowed and will not cause any problems.

    It's the standard behavior of the console. The attribute saves the reference to its object, and the console shows the referenced object when expanding the attribute.