Painting Blue Code
Simple, self-explanatory code snippets.
2015-11-15
MongoDB - Filter on a given field, if it exists
db.
COLLECTION_NAME
.find(
$or: [
{
FIELD_NAME
:
{
$exists
: false}}
, {
FIELD_NAME
:
EXACT_VALUE_TO_COMPARE_TO
}
]
);
db.
COLLECTION_NAME
.find(
FIELD_NAME
:
{
$ne
:
EXACT_VALUE_TO_COMPARE_TO
}
);
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment