Profile
Sign out
menu
create
New Post
My learned
Sign In
Find record with non-empty field
Mongo Db
To query a MongoDB collection where a specific field both
exists
and is
not empty
, you can use the following syntax in a MongoDB query (using the
find
method):
db.collection.find({ description: { $exists: true, $ne: "" } })
$exists: true
: ensures the field exists.
$ne: ""
: ensures the field is
not
an empty string.
arrow_back
back