Embedded symbols in MongoDB

Embedded symbols in MongoDB

I am new to querying MongoDB but am running into difficulty filtering Objects where certain symbols exist. For example:

I am new to querying MongoDB but am running into difficulty filtering Objects where certain symbols exist. For example:

I have a number Objects in my collection engine that are structured like this:

{
    "_id" : ObjectId("5c3a5efa6b0526729490cb2f"),
    "imsi" : "12345",
    "class_name" : "foo",
    "decoded_payload" : {
        "timestamp" : 1547329260,
        "lock_status" : "LOCKED"
    },
    "direction" : "in",
    "created_at" : ISODate("2019-01-12T21:41:14.998Z")
}

My objective is to get Objects whose imsi is 12345 that contain a decoded_payload that contains lock_status (lock status is of type symbol, not string). Many objects do not contain these keys so I want to filter out the ones that do.

The query runs, but returns zero results (although there are many Objects that should be returned). I am wondering if there is a syntax error that is overlooked because lock_status is of type symbol. What could be the error here?

My query:

db.getCollection('engine').find({

$and: [

{"decoded_payload":{
$exists: true,
$elemMatch: {"lock_status":{$exists:true} } 
    }
},

{"imsi": "12345"}


]})

.sort({"decoded_payload.timestamp":-1})


mongodb sql

What's new in Bootstrap 5 and when Bootstrap 5 release date?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Random Password Generator Online

HTML Color Picker online | HEX Color Picker | RGB Color Picker

Introduction to Structured Query Language SQL pdf

SQL stands for Structured Query Language. SQL is a scripting language expected to store, control, and inquiry information put away in social databases. The main manifestation of SQL showed up in 1974, when a gathering in IBM built up the principal model of a social database. The primary business social database was discharged by Relational Software later turning out to be Oracle.

MongoDB Database and java applications

Enroll for free demo to acquire the best knowledge on the schema-less database from live industry experts through MongoDB training

MongoDB vs. SQL

MongoDB and SQL databases are two polar opposite sides of the backend world. We will do an in-depth comparison between MongoDB vs SQL databases, (to be precise MySQL database) and will also touch upon the important topic of how we can perform MongoDB analytics similar to the ease with which analytics are done on its SQL counterparts.

Learn SQL & MongoDb Simultaneously

Learning MongoDB and SQL has never been much easier than this. By the end of this series you’ll be a PRO in MongoDB and SQL, Trust me.

Which is the Best MongoDB GUI?

Our MongoDB Online Training provide you to learn about MongoDB strategies with realty. Our MongoDB Online Training also includes live sessions, live Projects, and much