I want to make an endpoint in my application to check if a slug already exists
I made in this way:
connection := storage.DbBongo()
connection.Collection("mycollection").FindOne(bson.M{"slug": slug}, &post)
isAvailable := post.Id == ""
/// RESPONSE IF IS AVAILABLE AFTER
But, in this query to MongoDb I'm getting all post data
I want to make a simple query getting only if exist or not
Hello guys
I want to make an endpoint in my application to check if a slug already exists I made in this way:
But, in this query to MongoDb I'm getting all post data I want to make a simple query getting only if exist or not
To simplify, I want to count
Like this:
How can I do this?
Thanks