Advertisement
Guest User

Untitled

a guest
Jun 1st, 2021
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. Suppose I created this relationship attribute set and it has four 4 attributes
  2.  
  3. {
  4. id: 1,
  5. attribute: [
  6. {
  7. id: 1,
  8. attributeType: 1,
  9. },
  10. {
  11. id: 2,
  12. attributeType: 1,
  13. },
  14. {
  15. id: 3,
  16. attributeType: 1,
  17. },
  18. {
  19. id: 4,
  20. attributeType: 1,
  21. }
  22. ]
  23. }
  24.  
  25. Now the problem is how will we insert value in `text_value` column of `relationship_attribute_text_value` table associated with the above attribute id 1,2,3, 4
  26.  
  27. If the text_value column was in the `relationship_attribute` table we could have easily done that. (just like we have `value` column in identifier table or `source_bbid`, `target_bbid` column in `relationship` table we need the `text_value` column in the `relationship_attribute` table)
  28.  
  29.  
  30. If we go with our current schema the only workaround i can think of is looping through above attribute array and then inserting the value
  31. attribute.map(row => await new RelationshipAttributeTextValue({id: row.id value: 'someValue' }).save(null, {method: 'insert'}));
  32.  
  33. But again the problem arises here is that how will we know which value will be associated with which attribute id ?
  34.  
  35. Also if i am not wrong with the current schema the problem `changing an item in a series from position "1" to position "2", and comparing the two revisions?` will still remain if we keep the text_value column in a separate table.
  36.  
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement