multiple.joins.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /**
  2. * Joins
  3. *
  4. * @type {Array}
  5. */
  6. module.exports = [
  7. // N..M Populate
  8. // (Message has an association "to" which points to a collection of User)
  9. {
  10. parent: 'message', // left table name
  11. parentCollectionIdentity: 'message',
  12. parentKey: 'id', // left table key
  13. alias: 'to', // the `alias` -- e.g. name of association
  14. child: 'message_to_user', // right table name
  15. childKey: 'message_id', // right table key
  16. childCollectionIdentity: 'message_to_user'
  17. },
  18. {
  19. alias: 'to', // the `alias` -- e.g. name of association
  20. parent: 'message_to_user', // left table name
  21. parentCollectionIdentity: 'message_to_user',
  22. parentKey: 'user_id', // left table key
  23. child: 'user', // right table name
  24. childKey: 'id', // right table key
  25. select: ['id', 'email'],
  26. childCollectionIdentity: 'user'
  27. },
  28. // N..1 Populate
  29. // (Message has an association "from" which points to one User)
  30. {
  31. parent: 'message', // left table name
  32. parentCollectionIdentity: 'message',
  33. alias: 'from', // the `alias` -- e.g. name of association
  34. parentKey: 'from', // left table key
  35. child: 'user', // right table name
  36. childKey: 'id', // right table key
  37. select: ['email', 'id'],
  38. childCollectionIdentity: 'user'
  39. },
  40. // N..M Populate
  41. // (Message has an association "cc" which points to a collection of User)
  42. {
  43. parent: 'message', // left table name
  44. parentCollectionIdentity: 'message',
  45. parentKey: 'id', // left table key
  46. alias: 'cc', // the `alias` -- e.g. name of association
  47. child: 'message_cc_user', // right table name
  48. childKey: 'message_id', // right table key
  49. childCollectionIdentity: 'message_cc_user'
  50. },
  51. {
  52. alias: 'cc', // the `alias` -- e.g. name of association
  53. parent: 'message_cc_user', // left table name
  54. parentCollectionIdentity: 'message_cc_user',
  55. parentKey: 'user_id', // left table key
  56. child: 'user', // right table name
  57. childKey: 'id', // right table key
  58. select: ['id', 'email'],
  59. childCollectionIdentity: 'user'
  60. }
  61. ];