Closed danvoyce closed 3 years ago
There's actually more to it than this. Just investigating...
Ok, I just realised that the posts doc id is the same as the slug.
Mine was a randomly generated Id, hence the issue.
Out of interest, what is the correct query if we did want to find a post by one of the fields, as the one above isn't working.
I believe this works, but requires another index to be created
const postRef = userDoc.ref
.collection("posts")
.where("slug", "==", slug)
.orderBy("slug", "desc")
.limit(1);
On this line you're trying to fetch a document by the slug, but this will return nothing unless the slug is the document ID.
This line should simply be replaced with
Happy to submit a PR unless I'm missing something?