in mongo store object have field "titlecomposite". field contains array of title object, this:
"titlecomposite": [ "0": { "titletype": "01", "titletext": "test cover uploading" } ] i'm perfoming query , receive "titletext" value returned values. here example of query:
db.onix_feed.find({"addedby":201, "mediafilecomposite":{$exists:false}}, {"isbn13":1,"titlecomposite.titletext":1}) in results see values like
{ "_id" : objectid("559ab286fa4634f309826385"), "titlecomposite" : [ { "titletext" : "the nonprofit world" } ], "isbn13" : "9781565495296" } is there way rid of "titlecomposite" wrapper object , receive titletext? example, take titletext of first element only?
would appreciate help
you can mongodb aggregation achieve expected result. re-arrange query following...
db.onix_feed.aggregate([ { $match: { $and: [ {"addedby":201}, {"mediafilecomposite":{$exists:false}} ] } }, { $project : { titletext: "$titlecomposite.titletext", "isbn13" : 1 } } ])
Comments
Post a Comment