node.js - How to query object property(Field) in mongoose? -
i want document using mediaid placed inside mongoose object field
schema
mongoose = require 'mongoose' schema = mongoose.schema promise = require "bluebird" db_name = 'test' fields = presentationid: string customerid: string json: object collection = collection: db_name schema = new schema fields, collection schema.plugin timestamps model = mongoose.model db_name, schema promise.promisifyall model module.exports = model module.exports.col = db_name
db follows
{ "presentationid": "58e38fdbb9d4f20dc5f0bbcd", "customerid": "589b2599f304602ff8a17490", "json": { "objects": [ { "mediaid": "58e34c8454a8d361ea6967e7", "duration": 10, "name": "image1.png", "height": 92, "width": 272, "top": 12.61, "left": 25.26, "type": "image" }, { "mediaid": "58e34c8454a8d361ea6967e7", "duration": 10, "name": "image2.png", "height": 92, "width": 272, "top": 12.61, "left": 25.26, "type": "image" }, { "mediaid": "58e34c8454a8d361ea6967e8", "duration": 10, "name": "image3.png", "height": 92, "width": 272, "top": 12.61, "left": 25.26, "type": "image" } ] } }
the above code schema , database documents here want document if mediaid matched db mediaid ex:
query = json: objects: mediaid: "58e34c8454a8d361ea6967e7"
Comments
Post a Comment