Fork me on GitHub
#architecture
<
2018-04-27
>
drewverlee14:04:02

If you asked a document store for a key that didn’t exist. Would you expect a) a 400 type response b) a empty document

ivan.kanak_clojurians15:04:26

an empty document is still a document - it doesn't signify non-existence

drewverlee17:04:44

@ivan.kanak_clojurians me too. And yet, I seem to have not explained this well enough to my co workers. I think there suggesting they in this specific case it's more convenient, but I'm worried it's going to be very confusing for someone else that isn't in on this choice. They wanted to compare it to what happens when you ask for rows in a relational db but I think it's more like asking for a table that doesn't exist...

seancorfield19:04:06

In SQL, you ask for a result set, and an empty response means "no matches". For a document store, you can ask for "matching documents" and an empty response means "no match" but if you ask for a specific document, an empty document should mean "I found a match and it was this empty document". That's the key difference: SQL is always plural in results (a ResultSet); document stores tend to offer both "find one" and "find all" -- the latter corresponds to SQL.

seancorfield19:04:53

Returning nil for "no matching document" would be OK for the singular case if the client is within the same code, otherwise, yes 404 is the right response (for document-store-as-a-service).