Skip to content

Instantly share code, notes, and snippets.

@jsmney
Last active April 29, 2024 02:19
Show Gist options
  • Save jsmney/012c5e123d343171e2bc12ced6553bbe to your computer and use it in GitHub Desktop.
Save jsmney/012c5e123d343171e2bc12ced6553bbe to your computer and use it in GitHub Desktop.
Method Relationship Parameter Returns Side effects / notes
cat.addOwner() M:M owner {}, or ownerId created join table row
cat.addOwners() M:M array of owner {} or ownerId, can be a combination array of created join table rows
cat.countOwners() M:M none int
cat.createOwner() 1:1, 1:M, M:M new owner {} (what you could also pass into Owner.create() ) created owner object cat instance will have updated ownerId
cat.getOwner() 1:1, 1:M none owner object (if exists), or null
cat.getOwners() M:M none array of owner object(s)
cat.hasOwner() M:M owner {}, or ownerId boolean
cat.hasOwners() M:M array of owner {} or ownerId, can be a combination boolean returns true only if ALL owners own this cat
cat.removeOwner() M:M owner {}, or ownerId int number of owners removed
cat.removeOwners() M:M array of owner {} or ownerId, can be a combination int number of owners removed
cat.setOwner() 1:1, 1:M owner {}, or ownerId cat object with updated ownerId
owner.addCat() 1:M, M:M cat {}, or catId owner object if 1:M, created join table row if M:M
owner.addCats() 1:M, M:M array of cat {} or catId, can be a combination owner object if 1:M, array of created join table rows if M:M
owner.countCats() 1:M, M:M none int
owner.createCat() 1:1, 1:M, M:M new cat {} (what you could also pass into Cat.create() ) created cat {} with associated ownerId
owner.getCat() 1:1 none cat object (if exists), or null
owner.getCats() 1:M, M:M none array of cat {}
owner.hasCat() 1:M, M:M cat {}, or catId boolean
owner.hasCats() 1:M, M:M array of cat {} or catId, can be a combination boolean returns true only if ALL cats are owned
owner.removeCat() 1:M, M:M cat {}, or catId object 'cats' (referencing the table) if 1:M, # rows removed if M:M
owner.removeCats() 1:M, M:M array of cat {} or catId, can be a combination object 'cats' (referencing the table) if 1:M,# rows removed if M:M
owner.setCat() 1:1 cat {}, or catId cat object with updated ownerId
owner.setCats() 1:M, M:M array of cat {} or catId, can be a combination owner {} sets cats to input list, removing any other associated cats
@kundankumarKD
Copy link

hey it is amazing, a big thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment