I have two collections: persons and pets. A person may have as many pets as they want.
Person document:
person { id: person-id data: person-info}Pet document:
pet { id: pet-id data: pet-info personId: person-id}This is my API naming design
- GET all pets from a person: /api/pets/:personId
- GET all pets with condition: /api/pets/:personId?age_greater_than=4
- POST create new pet: /api/pets with the request body that contains person-id
- PUT update pet info: /api/pets/:petId with the request body that contains person-id and updated info
- DELETE delete pet: /api/pets/:personId with request body that contains pet-ids
Is there something wrong with my API naming convention and how can this be improved? I think that passing person-id directly to /api/pets is kind of weird.