Skip to content
Discussion options

You must be logged in to vote

It just came to my mind that I have not updated the solution on this.


When a record hasMany relations, the related objects are referenced by ID. For example, if an article can be read by front-desk or management, then the database is represented as followed.

articleNo1: {
  whoCanRead: [
    0: "123",
    1: "456",
  ]
}

roles: {
  front-desk: {
    id: "123"
  },
  management: {
    id: "456"
  },
}

Hence comparison should be based on object.id, not object.otherValue.


Each query is considered an object itself, we can construct a dynamic query for many-to-many comparisons. Let's have a sample context here:

  • John has two roles: Front-desk and Management
  • Article can be read by two roles…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by hunghvu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant