embedded-documents

mongodb mongoengine filter document on nexted EmbeddedDocumentLIst fields

本秂侑毒 提交于 2021-01-29 15:23:10
问题 I have a document with a EmbeddedDocumentList inside an other EmbeddedDocumentlist, I need to filter the collections retrieving only the documents that have a specified value for a field inside the inner EmbeddedDocumentList the reduced version of my models is: class RecipeIngredient(EmbeddedDocument): ingredient = ReferenceField(Ingredient, required=True) quantity = IntField(required=True) class RecipeLocalData(EmbeddedDocument): price = FloatField(required=True) enabled = BooleanField

MongoDB - $addToSet on a list of Embedded Document

折月煮酒 提交于 2019-12-30 06:09:28
问题 I have a list of (mongodb) Embedded Documents within one Document and I am interested in adding a new embedded document to the list of the existing ones. As far as I have researched, I can use $addToSet, what I can't figure out is how does MongoDB decide if the new document already exists in the list of embedded documents or if it's a new one, i.e. how does MongoDB decide if 2 embedded documents are equal? p.s. the embedded documents I have are not just values, they are quite complex

Is there a way to return specific nested fields from a query in MongoDB?

六眼飞鱼酱① 提交于 2019-12-25 00:19:35
问题 Is there a way to get the amount of money paid per Sport's category ? It can't be restricted only to "John," but in all collection documents. Expected query return for data provided: { {"Fight": [100,95] }, {"Running": [50] } } Example of data: {"_id":"5z621578b0ce483b9866fb1f", "Name":"John", "Sports":[ {"Category":"Fight", "Billing":[ {"Month":"Jan", "Status":"Paid", "Price":100}, {"Month":"Feb", "Status":"Not Paid", "Price":125}, {"Month":"Mar", "Status":"Paid", "Price":95} ] }, {"Category

Auto calculating fields in mongodb

删除回忆录丶 提交于 2019-12-21 23:39:00
问题 Let's say there are documents in MongoDB, that look something like this: { "lastDate" : ISODate("2013-14-01T16:38:16.163Z"), "items":[ {"date":ISODate("2013-10-01T16:38:16.163Z")}, {"date":ISODate("2013-11-01T16:38:16.163Z")}, {"date":ISODate("2013-12-01T16:38:16.163Z")}, {"date":ISODate("2013-13-01T16:38:16.163Z")}, {"date":ISODate("2013-14-01T16:38:16.163Z")} ] } Or even like this: { "allAre" : false, "items":[ {"is":true}, {"is":true}, {"is":true}, {"is":false}, {"is":true} ] } The top

Insert an embedded document to a new field in mongodb document

霸气de小男生 提交于 2019-12-21 16:49:57
问题 I have a document in mongodb collection like this: { _id: 133, Name: "abc", Price: 20 } I would like to add a new field "PackSizes" which may be or not may be of an array type, and then would like to an embedded document in it. Like- PackSizes: [ {_id: 123, PackSizeName:"xyz", UnitName:"pqr"} ] or, PackSizes: {_id: 123, PackSizeName:"xyz", UnitName:"pqr"} I'm a newcomer to mongodb. Please help. 回答1: You can do it with db.test.update( { _id : 133 }, { $set : { PackSizes: {_id: 123,

Parent file address, in embedded word doc fields is absoluted

旧城冷巷雨未停 提交于 2019-12-04 02:33:25
问题 How can made it relative? I have "WB1.xlsm" in "E:\Administration\Salary" . A word document was embedded in Sheet1 : (Microsoft Word Macro-Enabled Document object) I did Copy & Paste Cells(2,1) in the embedded word doc as Paste Special > Paste Link There is an absolute parent file address have generated in the field's code: LINK Excel.SheetMacroEnabled.12 "E:\Administration\Salary\\WB1.xlsm" "Sheet1!R2C1" \a \f 4 \r \* MERGEFORMAT So I can't move the Excel file. How can make the parent file

MongoDB: How to find a document by an id inside a nested document

独自空忆成欢 提交于 2019-12-03 13:54:33
问题 Given a collection like this:.. [ { "_id" : ObjectId("5546329a470000850084a621"), "name": "Joe", "surname": "Smith", "accounts": [ { "_id" : ObjectId("5546329a470000850084a655"), "default": true, "status" : "approved", "activationTime" : ISODate("2013-05-03T14:37:15.025Z") }, { "_id" : ObjectId("5546329a470000850084a688"), "default": true, "status" : "approved", "activationTime" : ISODate("2014-06-03T14:37:15.025Z") } ] }, { "_id" : ObjectId("9546329a470079850084a622"), "name": "Jimmy",

MongoDB: How to find a document by an id inside a nested document

落花浮王杯 提交于 2019-12-03 06:44:39
Given a collection like this:.. [ { "_id" : ObjectId("5546329a470000850084a621"), "name": "Joe", "surname": "Smith", "accounts": [ { "_id" : ObjectId("5546329a470000850084a655"), "default": true, "status" : "approved", "activationTime" : ISODate("2013-05-03T14:37:15.025Z") }, { "_id" : ObjectId("5546329a470000850084a688"), "default": true, "status" : "approved", "activationTime" : ISODate("2014-06-03T14:37:15.025Z") } ] }, { "_id" : ObjectId("9546329a470079850084a622"), "name": "Jimmy", "surname": "Brown", "accounts": [ { "_id" : ObjectId("5546329a470790850084a651"), "default": true, "status"

Parent file address, in embedded word doc fields is absoluted

旧时模样 提交于 2019-12-01 14:19:05
How can made it relative? I have "WB1.xlsm" in "E:\Administration\Salary" . A word document was embedded in Sheet1 : (Microsoft Word Macro-Enabled Document object) I did Copy & Paste Cells(2,1) in the embedded word doc as Paste Special > Paste Link There is an absolute parent file address have generated in the field's code: LINK Excel.SheetMacroEnabled.12 "E:\Administration\Salary\\WB1.xlsm" "Sheet1!R2C1" \a \f 4 \r \* MERGEFORMAT So I can't move the Excel file. How can make the parent file address which is in linked fields, related to the application.path of parent document? parent document

MongoDB - $addToSet on a list of Embedded Document

我怕爱的太早我们不能终老 提交于 2019-11-30 19:06:18
I have a list of (mongodb) Embedded Documents within one Document and I am interested in adding a new embedded document to the list of the existing ones. As far as I have researched, I can use $addToSet, what I can't figure out is how does MongoDB decide if the new document already exists in the list of embedded documents or if it's a new one, i.e. how does MongoDB decide if 2 embedded documents are equal? p.s. the embedded documents I have are not just values, they are quite complex structures, so I was wondering if there is any place I can define what the equality between 2 of them means...